summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalin <[email protected]>2022-07-13 05:50:31 -0600
committerGitHub <[email protected]>2022-07-13 04:50:31 -0700
commit9db5de109c166aa802b85cfae2dced3c4728a00d (patch)
treeea6290eb952764ba64cde11180fea48b5008fad9
parent7bff4ca7addde8cc54c38f5db1e50fa420189a20 (diff)
Set BasicAuth in http.go only if username and password are not empty (#914)
This prevents error "read/write on closed pipe". Go's http.client::send() always closes req.Body, so if the first request attempt is unsuccessful, any subsequent requests after calling the `CredentialsCallback` will attempt to read/write on a closed pipe.
-rw-r--r--http.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/http.go b/http.go
index 0777c56..cb4c7d0 100644
--- a/http.go
+++ b/http.go
@@ -203,7 +203,9 @@ func (self *httpSmartSubtransportStream) sendRequest() error {
req.ContentLength = -1
}
- req.SetBasicAuth(userName, password)
+ if userName != "" && password != "" {
+ req.SetBasicAuth(userName, password)
+ }
resp, err = http.DefaultClient.Do(req)
if err != nil {
return err