From: Brad Fitzpatrick Date: Tue, 29 May 2012 21:27:07 +0000 (-0700) Subject: net/http: better comment in hasToken X-Git-Tag: go1.1rc2~3077 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=253d7f0460e6547788d707a2f4e5e5b0c0301b2d;p=gostls13.git net/http: better comment in hasToken R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6249065 --- diff --git a/src/pkg/net/http/header.go b/src/pkg/net/http/header.go index d584c799f9..0eca817d7a 100644 --- a/src/pkg/net/http/header.go +++ b/src/pkg/net/http/header.go @@ -99,6 +99,11 @@ func hasToken(v, token string) bool { } for sp := 0; sp <= len(v)-len(token); sp++ { // Check that first character is good. + // The token is ASCII, so checking only a single byte + // is sufficient. We skip this potential starting + // position if both the first byte and its potential + // ASCII uppercase equivalent (b|0x20) don't match. + // False positives ('^' => '~') are caught by EqualFold. if b := v[sp]; b != token[0] && b|0x20 != token[0] { continue }