Set BasicAuth in http.go only if username and password are not empty #914

Merged
clns merged 1 commits from http-basic-auth into main 2022-07-13 06:50:31 -05:00
1 changed files with 3 additions and 1 deletions

View File

@ -203,7 +203,9 @@ func (self *httpSmartSubtransportStream) sendRequest() error {
req.ContentLength = -1 req.ContentLength = -1
} }
req.SetBasicAuth(userName, password) if userName != "" && password != "" {
req.SetBasicAuth(userName, password)
}
resp, err = http.DefaultClient.Do(req) resp, err = http.DefaultClient.Do(req)
if err != nil { if err != nil {
return err return err