Commit cd95c68b authored by Ivan Babrou's avatar Ivan Babrou Committed by Brad Fitzpatrick

http2: mention bogus header value in error messages

Change-Id: I69d713341b878a2343bb85fb2de2ef49441fd16d
Reviewed-on: https://go-review.googlesource.com/30098
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 1f79cc9b
......@@ -624,13 +624,13 @@ func (cc *ClientConn) responseHeaderTimeout() time.Duration {
// Certain headers are special-cased as okay but not transmitted later.
func checkConnHeaders(req *http.Request) error {
if v := req.Header.Get("Upgrade"); v != "" {
return errors.New("http2: invalid Upgrade request header")
return fmt.Errorf("http2: invalid Upgrade request header: %q", req.Header["Upgrade"])
}
if v := req.Header.Get("Transfer-Encoding"); (v != "" && v != "chunked") || len(req.Header["Transfer-Encoding"]) > 1 {
return errors.New("http2: invalid Transfer-Encoding request header")
return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", req.Header["Transfer-Encoding"])
}
if v := req.Header.Get("Connection"); (v != "" && v != "close" && v != "keep-alive") || len(req.Header["Connection"]) > 1 {
return errors.New("http2: invalid Connection request header")
return fmt.Errorf("http2: invalid Connection request header: %q", req.Header["Connection"])
}
return nil
}
......
......@@ -1707,12 +1707,12 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
{
key: "Upgrade",
value: []string{"anything"},
want: "ERROR: http2: invalid Upgrade request header",
want: "ERROR: http2: invalid Upgrade request header: [\"anything\"]",
},
{
key: "Connection",
value: []string{"foo"},
want: "ERROR: http2: invalid Connection request header",
want: "ERROR: http2: invalid Connection request header: [\"foo\"]",
},
{
key: "Connection",
......@@ -1722,7 +1722,7 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
{
key: "Connection",
value: []string{"close", "something-else"},
want: "ERROR: http2: invalid Connection request header",
want: "ERROR: http2: invalid Connection request header: [\"close\" \"something-else\"]",
},
{
key: "Connection",
......@@ -1742,7 +1742,7 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
{
key: "Transfer-Encoding",
value: []string{"foo"},
want: "ERROR: http2: invalid Transfer-Encoding request header",
want: "ERROR: http2: invalid Transfer-Encoding request header: [\"foo\"]",
},
{
key: "Transfer-Encoding",
......@@ -1752,7 +1752,7 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
{
key: "Transfer-Encoding",
value: []string{"chunked", "other"},
want: "ERROR: http2: invalid Transfer-Encoding request header",
want: "ERROR: http2: invalid Transfer-Encoding request header: [\"chunked\" \"other\"]",
},
{
key: "Content-Length",
......
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