From c92cdcb05f66ce5b61460e23498d2dc5fcf69aaf Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 15 Jan 2016 10:46:00 -0800 Subject: [PATCH] http2: make configureTransport return the new t2 transport as well This is needed so another CL in the main repo can keep the pointer around to pass through Transport.CloseIdleConnections from the http1 transport. This CL doesn't modify the exported ConfigureTransport signature. We'll use the private one in the standard library for now. (since it gets bundled into the same package) Updates golang/go#13975 Change-Id: I824e9ac4a44616c8c2a480f83bd3dc62bffc30e4 Reviewed-on: https://go-review.googlesource.com/18678 Reviewed-by: Andrew Gerrand Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- http2/configure_transport.go | 6 +++--- http2/not_go16.go | 4 ++-- http2/transport.go | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/http2/configure_transport.go b/http2/configure_transport.go index ac870770..0edcc34c 100644 --- a/http2/configure_transport.go +++ b/http2/configure_transport.go @@ -12,11 +12,11 @@ import ( "net/http" ) -func configureTransport(t1 *http.Transport) error { +func configureTransport(t1 *http.Transport) (*Transport, error) { connPool := new(clientConnPool) t2 := &Transport{ConnPool: noDialClientConnPool{connPool}} if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil { - return err + return nil, err } if t1.TLSClientConfig == nil { t1.TLSClientConfig = new(tls.Config) @@ -48,7 +48,7 @@ func configureTransport(t1 *http.Transport) error { } else { m["h2"] = upgradeFn } - return nil + return t2, nil } // registerHTTPSProtocol calls Transport.RegisterProtocol but diff --git a/http2/not_go16.go b/http2/not_go16.go index dbf6033f..db53c5b8 100644 --- a/http2/not_go16.go +++ b/http2/not_go16.go @@ -8,6 +8,6 @@ package http2 import "net/http" -func configureTransport(t1 *http.Transport) error { - return errTransportVersion +func configureTransport(t1 *http.Transport) (*Transport, error) { + return nil, errTransportVersion } diff --git a/http2/transport.go b/http2/transport.go index 5be19911..fc502400 100644 --- a/http2/transport.go +++ b/http2/transport.go @@ -113,7 +113,8 @@ var errTransportVersion = errors.New("http2: ConfigureTransport is only supporte // It requires Go 1.6 or later and returns an error if the net/http package is too old // or if t1 has already been HTTP/2-enabled. func ConfigureTransport(t1 *http.Transport) error { - return configureTransport(t1) // in configure_transport.go (go1.6) or go15.go + _, err := configureTransport(t1) // in configure_transport.go (go1.6) or not_go16.go + return err } func (t *Transport) connPool() ClientConnPool {