Commit 6f138e0f authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http2: compare Connection header value case-insensitively

The case was ignored elsewhere in this file, but not in this place.

Fixes golang/go#23699

Change-Id: I222092c10aab33d652df5d028cf93716955c20a5
Reviewed-on: https://go-review.googlesource.com/122588
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 4d581e05
......@@ -747,7 +747,7 @@ func checkConnHeaders(req *http.Request) error {
if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", vv)
}
if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "close" && vv[0] != "keep-alive") {
if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !strings.EqualFold(vv[0], "close") && !strings.EqualFold(vv[0], "keep-alive")) {
return fmt.Errorf("http2: invalid Connection request header: %q", vv)
}
return nil
......
......@@ -2022,6 +2022,11 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
value: []string{"close"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Connection",
value: []string{"CLoSe"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Connection",
value: []string{"close", "something-else"},
......@@ -2032,6 +2037,11 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
value: []string{"keep-alive"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Connection",
value: []string{"Keep-ALIVE"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Proxy-Connection", // just deleted and ignored
value: []string{"keep-alive"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment