Skip to content

Commit fdefaba

Browse files
narqobradfitz
authored andcommitted
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: eb08aea GitHub-Pull-Request: #27817 Reviewed-on: https://go-review.googlesource.com/136762 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent ce58a39 commit fdefaba

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

src/net/http/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d
238238
username := u.Username()
239239
password, _ := u.Password()
240240
forkReq()
241-
req.Header = cloneHeader(ireq.Header)
241+
req.Header = ireq.Header.clone()
242242
req.Header.Set("Authorization", "Basic "+basicAuth(username, password))
243243
}
244244

src/net/http/header.go

-10
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,3 @@ func hasToken(v, token string) bool {
229229
func isTokenBoundary(b byte) bool {
230230
return b == ' ' || b == ',' || b == '\t'
231231
}
232-
233-
func cloneHeader(h Header) Header {
234-
h2 := make(Header, len(h))
235-
for k, vv := range h {
236-
vv2 := make([]string, len(vv))
237-
copy(vv2, vv)
238-
h2[k] = vv2
239-
}
240-
return h2
241-
}

0 commit comments

Comments
 (0)