Skip to content

Commit 9db5de1

Browse files
authored
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.
1 parent 7bff4ca commit 9db5de1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

http.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ func (self *httpSmartSubtransportStream) sendRequest() error {
203203
req.ContentLength = -1
204204
}
205205

206-
req.SetBasicAuth(userName, password)
206+
if userName != "" && password != "" {
207+
req.SetBasicAuth(userName, password)
208+
}
207209
resp, err = http.DefaultClient.Do(req)
208210
if err != nil {
209211
return err

0 commit comments

Comments
 (0)