Skip to content

Commit

Permalink
net/http: fix bug where http2 wasn't enabled on DefaultTransport
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bradfitz authored and adg committed Apr 14, 2016
1 parent f5cf567 commit 406752b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/net/http/transport.go
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/net/http/transport_test.go
Expand Up @@ -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),
Expand Down

0 comments on commit 406752b

Please sign in to comment.