diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-05-18 20:07:16 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-05-18 20:53:43 +0000 |
| commit | 1efec481d0997e260f4524d45d11cc35bed63f73 (patch) | |
| tree | 4b9370fa3c736a306f518d13b75d1d0db521a7ab /src/net/http | |
| parent | 1249197936aef58cb2296a3cd57b519ba3243042 (diff) | |
| download | go-1efec481d0997e260f4524d45d11cc35bed63f73.tar.xz | |
net/http: further restrict when Transport's automatic HTTP/2 happens
Make the temporary, conservative restrictions from rev 79d9f48c in Go
1.6 permanent, and also don't do automatic TLS if the user configured
a Dial or DialTLS hook. (Go 1.7 has Transport.Dialer instead, for
tweaking dialing parameters)
Fixes #14275
Change-Id: I5550d5c1e3a293e103eb4251a3685dc204a23941
Reviewed-on: https://go-review.googlesource.com/23222
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http')
| -rw-r--r-- | src/net/http/transport.go | 13 | ||||
| -rw-r--r-- | src/net/http/transport_test.go | 15 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 865dbdd508..17e6270151 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -195,13 +195,12 @@ func (t *Transport) onceSetNextProtoDefaults() { // Transport. return } - if t.TLSClientConfig != nil { - // Be conservative for now (for Go 1.6) at least and - // don't automatically enable http2 if they've - // specified a custom TLS config. Let them opt-in - // themselves via http2.ConfigureTransport so we don't - // surprise them by modifying their tls.Config. - // Issue 14275. + if t.TLSClientConfig != nil || t.Dial != nil || t.DialTLS != nil { + // Be conservative and don't automatically enable + // http2 if they've specified a custom TLS config or + // custom dialers. Let them opt-in themselves via + // http2.ConfigureTransport so we don't surprise them + // by modifying their tls.Config. Issue 14275. return } if t.ExpectContinueTimeout != 0 && t != DefaultTransport { diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index 48b1b309d3..ab05c31cb5 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -2986,6 +2986,21 @@ func TestTransportAutomaticHTTP2_ExpectContinueTimeout(t *testing.T) { }, false) } +func TestTransportAutomaticHTTP2_Dial(t *testing.T) { + var d net.Dialer + testTransportAutoHTTP(t, &Transport{ + Dial: d.Dial, + }, false) +} + +func TestTransportAutomaticHTTP2_DialTLS(t *testing.T) { + testTransportAutoHTTP(t, &Transport{ + DialTLS: func(network, addr string) (net.Conn, error) { + panic("unused") + }, + }, false) +} + func testTransportAutoHTTP(t *testing.T, tr *Transport, wantH2 bool) { _, err := tr.RoundTrip(new(Request)) if err == nil { |
