Commit fdefabad authored by Vladimir Varankin's avatar Vladimir Varankin Committed by Brad Fitzpatrick

net/http: use Header.clone rather then duplicating functionality

cloneHeader duplicates what Header.clone() method is doing. It's
used in a single place, which can be replaced with the use of the
method.

Change-Id: I6e8bbd6c95063f31ca3695f13fa7478873230525
GitHub-Last-Rev: eb08aeae9b4257df5cf08d6d30903ddeec6b6242
GitHub-Pull-Request: golang/go#27817
Reviewed-on: https://go-review.googlesource.com/136762Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ce58a39f
...@@ -238,7 +238,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d ...@@ -238,7 +238,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d
username := u.Username() username := u.Username()
password, _ := u.Password() password, _ := u.Password()
forkReq() forkReq()
req.Header = cloneHeader(ireq.Header) req.Header = ireq.Header.clone()
req.Header.Set("Authorization", "Basic "+basicAuth(username, password)) req.Header.Set("Authorization", "Basic "+basicAuth(username, password))
} }
......
...@@ -229,13 +229,3 @@ func hasToken(v, token string) bool { ...@@ -229,13 +229,3 @@ func hasToken(v, token string) bool {
func isTokenBoundary(b byte) bool { func isTokenBoundary(b byte) bool {
return b == ' ' || b == ',' || b == '\t' return b == ' ' || b == ',' || b == '\t'
} }
func cloneHeader(h Header) Header {
h2 := make(Header, len(h))
for k, vv := range h {
vv2 := make([]string, len(vv))
copy(vv2, vv)
h2[k] = vv2
}
return h2
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment