Skip to content

Commit c92cdcb

Browse files
committed
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 <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent a8e212f commit c92cdcb

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

http2/configure_transport.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212
"net/http"
1313
)
1414

15-
func configureTransport(t1 *http.Transport) error {
15+
func configureTransport(t1 *http.Transport) (*Transport, error) {
1616
connPool := new(clientConnPool)
1717
t2 := &Transport{ConnPool: noDialClientConnPool{connPool}}
1818
if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil {
19-
return err
19+
return nil, err
2020
}
2121
if t1.TLSClientConfig == nil {
2222
t1.TLSClientConfig = new(tls.Config)
@@ -48,7 +48,7 @@ func configureTransport(t1 *http.Transport) error {
4848
} else {
4949
m["h2"] = upgradeFn
5050
}
51-
return nil
51+
return t2, nil
5252
}
5353

5454
// registerHTTPSProtocol calls Transport.RegisterProtocol but

http2/not_go16.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ package http2
88

99
import "net/http"
1010

11-
func configureTransport(t1 *http.Transport) error {
12-
return errTransportVersion
11+
func configureTransport(t1 *http.Transport) (*Transport, error) {
12+
return nil, errTransportVersion
1313
}

http2/transport.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ var errTransportVersion = errors.New("http2: ConfigureTransport is only supporte
113113
// It requires Go 1.6 or later and returns an error if the net/http package is too old
114114
// or if t1 has already been HTTP/2-enabled.
115115
func ConfigureTransport(t1 *http.Transport) error {
116-
return configureTransport(t1) // in configure_transport.go (go1.6) or go15.go
116+
_, err := configureTransport(t1) // in configure_transport.go (go1.6) or not_go16.go
117+
return err
117118
}
118119

119120
func (t *Transport) connPool() ClientConnPool {

0 commit comments

Comments
 (0)