Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Simple-Tracker committed Oct 26, 2024
1 parent ec40ccf commit eae5579
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

var fetchFailedCount = 0

func NewRequest(isPOST bool, url string, postdata string, external bool, withHeader *map[string]string) *http.Request {
func NewRequest(isPOST bool, url string, postdata string, clientReq bool, withHeader *map[string]string) *http.Request {
var request *http.Request
var err error

Expand Down Expand Up @@ -47,29 +47,31 @@ func NewRequest(isPOST bool, url string, postdata string, external bool, withHea
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}

if currentClientType == "Transmission" && external && Tr_csrfToken != "" {
request.Header.Set("X-Transmission-Session-Id", Tr_csrfToken)
}
if clientReq {
if currentClientType == "Transmission" && Tr_csrfToken != "" {
request.Header.Set("X-Transmission-Session-Id", Tr_csrfToken)
}

if external && config.UseBasicAuth && config.ClientUsername != "" {
request.SetBasicAuth(config.ClientUsername, config.ClientPassword)
if config.UseBasicAuth && config.ClientUsername != "" {
request.SetBasicAuth(config.ClientUsername, config.ClientPassword)
}
}

return request
}
func Fetch(url string, tryLogin bool, external bool, withHeader *map[string]string) (int, http.Header, []byte) {
request := NewRequest(false, url, "", external, withHeader)
func Fetch(url string, tryLogin bool, clientReq bool, withHeader *map[string]string) (int, http.Header, []byte) {
request := NewRequest(false, url, "", clientReq, withHeader)
if request == nil {
return -1, nil, nil
}

var response *http.Response
var err error

if external {
if clientReq {
response, err = httpClient.Do(request)
} else {
response, err = httpClientExternal.Do(request)
response, err = httpClientclientReq.Do(request)

Check failure on line 74 in request.go

View workflow job for this annotation

GitHub Actions / Dev-CI-Test

undefined: httpClientclientReq
}

if err != nil {
Expand Down Expand Up @@ -141,19 +143,19 @@ func Fetch(url string, tryLogin bool, external bool, withHeader *map[string]stri

return response.StatusCode, response.Header, responseBody
}
func Submit(url string, postdata string, tryLogin bool, external bool, withHeader *map[string]string) (int, http.Header, []byte) {
request := NewRequest(true, url, postdata, external, withHeader)
func Submit(url string, postdata string, tryLogin bool, clientReq bool, withHeader *map[string]string) (int, http.Header, []byte) {
request := NewRequest(true, url, postdata, clientReq, withHeader)
if request == nil {
return -1, nil, nil
}

var response *http.Response
var err error

if external {
if clientReq {
response, err = httpClient.Do(request)
} else {
response, err = httpClientExternal.Do(request)
response, err = httpClientclientReq.Do(request)

Check failure on line 158 in request.go

View workflow job for this annotation

GitHub Actions / Dev-CI-Test

undefined: httpClientclientReq
}

if err != nil {
Expand Down

0 comments on commit eae5579

Please sign in to comment.