]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/httputil: also remove non-standard Proxy-Connection hop-by-hop header
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 3 Feb 2016 21:35:03 +0000 (21:35 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 3 Feb 2016 22:02:01 +0000 (22:02 +0000)
libcurl sends this (despite never being standardized), and the Google
GFE rejects it with a 400 bad request (but only when over http2?).

So nuke it.

Change-Id: I3fc95523d50f33a0e23bb26b9195f70ab0aed0f4
Reviewed-on: https://go-review.googlesource.com/19184
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

src/net/http/httputil/reverseproxy.go
src/net/http/httputil/reverseproxy_test.go

index 38987d7a741957e82e9ee36c9b0d70c025abe08c..54411caeca8f90472cf0aa220d53bf906bee0f79 100644 (file)
@@ -106,6 +106,7 @@ func copyHeader(dst, src http.Header) {
 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
 var hopHeaders = []string{
        "Connection",
+       "Proxy-Connection", // non-standard but still sent by libcurl and rejected by e.g. google
        "Keep-Alive",
        "Proxy-Authenticate",
        "Proxy-Authorization",
index 72662ccdc5c7e44e055b14546409a98ecdd062c3..0849427b85cce40f6e7a262d0db2806c2bb8f209 100644 (file)
@@ -45,6 +45,9 @@ func TestReverseProxy(t *testing.T) {
                if c := r.Header.Get("Upgrade"); c != "" {
                        t.Errorf("handler got Upgrade header value %q", c)
                }
+               if c := r.Header.Get("Proxy-Connection"); c != "" {
+                       t.Errorf("handler got Proxy-Connection header value %q", c)
+               }
                if g, e := r.Host, "some-name"; g != e {
                        t.Errorf("backend got Host header %q, want %q", g, e)
                }
@@ -72,6 +75,7 @@ func TestReverseProxy(t *testing.T) {
        getReq, _ := http.NewRequest("GET", frontend.URL, nil)
        getReq.Host = "some-name"
        getReq.Header.Set("Connection", "close")
+       getReq.Header.Set("Proxy-Connection", "should be deleted")
        getReq.Header.Set("Upgrade", "foo")
        getReq.Close = true
        res, err := http.DefaultClient.Do(getReq)