]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: fix bug where http2 wasn't enabled on DefaultTransport
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 18 Feb 2016 22:59:13 +0000 (04:29 +0530)
committerAndrew Gerrand <adg@golang.org>
Thu, 14 Apr 2016 05:20:09 +0000 (05:20 +0000)
I had accidentally disabled a headline feature at the last second. :(

Fixes #14391

Change-Id: I1992c9b801072b7538b95c55242be174075ff932
Reviewed-on: https://go-review.googlesource.com/19672
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/22035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/transport.go
src/net/http/transport_test.go

index baf71d5e85e2facf97294f64fa41dfdbdcc4c0b3..1e3ea11d9c5bca462b65f215f2402f7951830bef 100644 (file)
@@ -176,9 +176,13 @@ func (t *Transport) onceSetNextProtoDefaults() {
                // Issue 14275.
                return
        }
-       if t.ExpectContinueTimeout != 0 {
-               // Unsupported in http2, so disable http2 for now.
-               // Issue 13851.
+       if t.ExpectContinueTimeout != 0 && t != DefaultTransport {
+               // ExpectContinueTimeout is unsupported in http2, so
+               // if they explicitly asked for it (as opposed to just
+               // using the DefaultTransport, which sets it), then
+               // disable http2 for now.
+               //
+               // Issue 13851. (and changed in Issue 14391)
                return
        }
        t2, err := http2configureTransport(t)
index 0c901b30a44771528860e54926b0fe683a66a5ac..d9da078fa0098f5c1d2513874710c221e73edbb3 100644 (file)
@@ -2888,6 +2888,11 @@ func TestTransportAutomaticHTTP2(t *testing.T) {
        testTransportAutoHTTP(t, &Transport{}, true)
 }
 
+// golang.org/issue/14391: also check DefaultTransport
+func TestTransportAutomaticHTTP2_DefaultTransport(t *testing.T) {
+       testTransportAutoHTTP(t, DefaultTransport.(*Transport), true)
+}
+
 func TestTransportAutomaticHTTP2_TLSNextProto(t *testing.T) {
        testTransportAutoHTTP(t, &Transport{
                TLSNextProto: make(map[string]func(string, *tls.Conn) RoundTripper),