diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-01-19 05:10:58 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-01-19 05:31:38 +0000 |
| commit | c40a73d80c38eacc27e8cb9cf25c2bacaee60a3d (patch) | |
| tree | 899eabd39d32eac57a4d76811728474bbcdaab5d /src/net/http/clientserver_test.go | |
| parent | 3208d92b78eed4d6abfedf3799f51b37826351a6 (diff) | |
| download | go-c40a73d80c38eacc27e8cb9cf25c2bacaee60a3d.tar.xz | |
net/http: make hidden http2 Transport respect remaining Transport fields
Updates x/net/http2 to git rev 72aa00c6 for https://golang.org/cl/18721
(but actually at https://golang.org/cl/18722 now)
Fixes #14008
Change-Id: If05d5ad51ec0ba5ba7e4fe16605c0a83f0484bc8
Reviewed-on: https://go-review.googlesource.com/18723
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/clientserver_test.go')
| -rw-r--r-- | src/net/http/clientserver_test.go | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go index 573ed93c05..9c1aa7920e 100644 --- a/src/net/http/clientserver_test.go +++ b/src/net/http/clientserver_test.go @@ -47,7 +47,7 @@ const ( h2Mode = true ) -func newClientServerTest(t *testing.T, h2 bool, h Handler) *clientServerTest { +func newClientServerTest(t *testing.T, h2 bool, h Handler, opts ...interface{}) *clientServerTest { cst := &clientServerTest{ t: t, h2: h2, @@ -55,6 +55,16 @@ func newClientServerTest(t *testing.T, h2 bool, h Handler) *clientServerTest { tr: &Transport{}, } cst.c = &Client{Transport: cst.tr} + + for _, opt := range opts { + switch opt := opt.(type) { + case func(*Transport): + opt(cst.tr) + default: + t.Fatalf("unhandled option type %T", opt) + } + } + if !h2 { cst.ts = httptest.NewServer(h) return cst @@ -139,6 +149,7 @@ type h12Compare struct { Handler func(ResponseWriter, *Request) // required ReqFunc reqFunc // optional CheckResponse func(proto string, res *Response) // optional + Opts []interface{} } func (tt h12Compare) reqFunc() reqFunc { @@ -149,9 +160,9 @@ func (tt h12Compare) reqFunc() reqFunc { } func (tt h12Compare) run(t *testing.T) { - cst1 := newClientServerTest(t, false, HandlerFunc(tt.Handler)) + cst1 := newClientServerTest(t, false, HandlerFunc(tt.Handler), tt.Opts...) defer cst1.close() - cst2 := newClientServerTest(t, true, HandlerFunc(tt.Handler)) + cst2 := newClientServerTest(t, true, HandlerFunc(tt.Handler), tt.Opts...) defer cst2.close() res1, err := tt.reqFunc()(cst1.c, cst1.ts.URL) @@ -380,6 +391,20 @@ func TestH12_AutoGzip(t *testing.T) { }.run(t) } +func TestH12_AutoGzip_Disabled(t *testing.T) { + h12Compare{ + Opts: []interface{}{ + func(tr *Transport) { tr.DisableCompression = true }, + }, + Handler: func(w ResponseWriter, r *Request) { + fmt.Fprintf(w, "%q", r.Header["Accept-Encoding"]) + if ae := r.Header.Get("Accept-Encoding"); ae != "" { + t.Errorf("%s Accept-Encoding = %q; want empty", r.Proto, ae) + } + }, + }.run(t) +} + // Test304Responses verifies that 304s don't declare that they're // chunking in their response headers and aren't allowed to produce // output. |
