Commit c92cdcb0 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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/18678Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent a8e212f3
...@@ -12,11 +12,11 @@ import ( ...@@ -12,11 +12,11 @@ import (
"net/http" "net/http"
) )
func configureTransport(t1 *http.Transport) error { func configureTransport(t1 *http.Transport) (*Transport, error) {
connPool := new(clientConnPool) connPool := new(clientConnPool)
t2 := &Transport{ConnPool: noDialClientConnPool{connPool}} t2 := &Transport{ConnPool: noDialClientConnPool{connPool}}
if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil { if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil {
return err return nil, err
} }
if t1.TLSClientConfig == nil { if t1.TLSClientConfig == nil {
t1.TLSClientConfig = new(tls.Config) t1.TLSClientConfig = new(tls.Config)
...@@ -48,7 +48,7 @@ func configureTransport(t1 *http.Transport) error { ...@@ -48,7 +48,7 @@ func configureTransport(t1 *http.Transport) error {
} else { } else {
m["h2"] = upgradeFn m["h2"] = upgradeFn
} }
return nil return t2, nil
} }
// registerHTTPSProtocol calls Transport.RegisterProtocol but // registerHTTPSProtocol calls Transport.RegisterProtocol but
......
...@@ -8,6 +8,6 @@ package http2 ...@@ -8,6 +8,6 @@ package http2
import "net/http" import "net/http"
func configureTransport(t1 *http.Transport) error { func configureTransport(t1 *http.Transport) (*Transport, error) {
return errTransportVersion return nil, errTransportVersion
} }
...@@ -113,7 +113,8 @@ var errTransportVersion = errors.New("http2: ConfigureTransport is only supporte ...@@ -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 // 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. // or if t1 has already been HTTP/2-enabled.
func ConfigureTransport(t1 *http.Transport) error { 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 { func (t *Transport) connPool() ClientConnPool {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment