Commit 024ed629 authored by Roland Shoemaker's avatar Roland Shoemaker Committed by Brad Fitzpatrick

http2: Ignore Keep-Alive header in requests

Adds Keep-Alive to the list of ignored headers in encodeHeaders
as required in the HTTP/2 spec (section 8.1.2.2) and adds a test
to check this.

Fixes golang/go#15085

Change-Id: Ie4624680c5de1f13eb94fa58a2d5d67a02634df3
Reviewed-on: https://go-review.googlesource.com/21482Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3e8a7b03
......@@ -945,14 +945,11 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
// Host is :authority, already sent.
// Content-Length is automatic, set below.
continue
case "connection", "proxy-connection", "transfer-encoding", "upgrade":
case "connection", "proxy-connection", "transfer-encoding", "upgrade", "keep-alive":
// Per 8.1.2.2 Connection-Specific Header
// Fields, don't send connection-specific
// fields. We deal with these earlier in
// RoundTrip, deciding whether they're
// error-worthy, but we don't want to mutate
// the user's *Request so at this point, just
// skip over them at this point.
// fields. We have already checked if any
// are error-worthy so just ignore the rest.
continue
case "user-agent":
// Match Go's http1 behavior: at most one
......
......@@ -1642,6 +1642,11 @@ func TestTransportRejectsConnHeaders(t *testing.T) {
value: []string{"123"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Keep-Alive",
value: []string{"doop"},
want: "Accept-Encoding,User-Agent",
},
}
for _, tt := range tests {
......
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