net/http: correct and faster hasToken

Fixes #3535

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6245060
This commit is contained in:
Brad Fitzpatrick 2012-05-28 10:55:39 -07:00
parent cb62365f57
commit 469e3a91d4
3 changed files with 78 additions and 8 deletions

View file

@ -745,11 +745,3 @@ func (r *Request) wantsHttp10KeepAlive() bool {
func (r *Request) wantsClose() bool {
return hasToken(r.Header.Get("Connection"), "close")
}
func hasToken(s, token string) bool {
if s == "" {
return false
}
// TODO This is a poor implementation of the RFC. See http://golang.org/issue/3535
return strings.Contains(strings.ToLower(s), token)
}