Skip to content

Commit

Permalink
net/http: do not overwrite valid Authorization headers just because a…
Browse files Browse the repository at this point in the history
… username is in the URL

See golang#11399

Change-Id: I3be7fbc86c5f62761f47122632f3e11b56cb6be6
  • Loading branch information
sinbad committed Jun 25, 2015
1 parent 751eef8 commit 4f57d35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/net/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func send(req *Request, t RoundTripper) (resp *Response, err error) {
req.Header = make(Header)
}

if u := req.URL.User; u != nil {
if u := req.URL.User; u != nil && req.Header.Get("Authorization") == "" {
username := u.Username()
password, _ := u.Password()
req.Header.Set("Authorization", "Basic "+basicAuth(username, password))
Expand Down

0 comments on commit 4f57d35

Please sign in to comment.