mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http: avoid a bunch of unnecessary CanonicalHeaderKey calls
CanonicalHeaderKey didn't allocate, but it did use unnecessary CPU in the hot path, deciding it didn't need to allocate. I considered using constants for all these common header keys but I didn't think it would be prettier. "Content-Length" looks better than contentLength or hdrContentLength, etc. R=golang-dev, dave CC=golang-dev https://golang.org/cl/6255053
This commit is contained in:
parent
c238031b2d
commit
1e814df79b
4 changed files with 26 additions and 18 deletions
|
|
@ -513,7 +513,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err error) {
|
|||
// the same. In the second case, any Host line is ignored.
|
||||
req.Host = req.URL.Host
|
||||
if req.Host == "" {
|
||||
req.Host = req.Header.Get("Host")
|
||||
req.Host = req.Header.get("Host")
|
||||
}
|
||||
req.Header.Del("Host")
|
||||
|
||||
|
|
@ -732,16 +732,16 @@ func (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, e
|
|||
}
|
||||
|
||||
func (r *Request) expectsContinue() bool {
|
||||
return hasToken(r.Header.Get("Expect"), "100-continue")
|
||||
return hasToken(r.Header.get("Expect"), "100-continue")
|
||||
}
|
||||
|
||||
func (r *Request) wantsHttp10KeepAlive() bool {
|
||||
if r.ProtoMajor != 1 || r.ProtoMinor != 0 {
|
||||
return false
|
||||
}
|
||||
return hasToken(r.Header.Get("Connection"), "keep-alive")
|
||||
return hasToken(r.Header.get("Connection"), "keep-alive")
|
||||
}
|
||||
|
||||
func (r *Request) wantsClose() bool {
|
||||
return hasToken(r.Header.Get("Connection"), "close")
|
||||
return hasToken(r.Header.get("Connection"), "close")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue