mirror of https://github.com/golang/go.git
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: eb08aeae9b
GitHub-Pull-Request: golang/go#27817
Reviewed-on: https://go-review.googlesource.com/136762
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ce58a39fca
commit
fdefabadf0
|
|
@ -238,7 +238,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d
|
|||
username := u.Username()
|
||||
password, _ := u.Password()
|
||||
forkReq()
|
||||
req.Header = cloneHeader(ireq.Header)
|
||||
req.Header = ireq.Header.clone()
|
||||
req.Header.Set("Authorization", "Basic "+basicAuth(username, password))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -229,13 +229,3 @@ func hasToken(v, token string) bool {
|
|||
func isTokenBoundary(b byte) bool {
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue