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>
// 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 {
}, 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 {