@@ -230,9 +230,6 @@ type Transport struct {
230
230
// automatically.
231
231
TLSNextProto map [string ]func (authority string , c * tls.Conn ) RoundTripper
232
232
233
- // TODO(gerg): Consider this public interface change for Transport
234
- UpgradeNextProto map [string ]func (string , * tls.Conn ) UpgradableRoundTripper
235
-
236
233
// ProxyConnectHeader optionally specifies headers to send to
237
234
// proxies during CONNECT requests.
238
235
ProxyConnectHeader Header
@@ -259,6 +256,7 @@ type Transport struct {
259
256
nextProtoOnce sync.Once
260
257
h2transport h2Transport // non-nil if http2 wired up
261
258
tlsNextProtoWasNil bool // whether TLSNextProto was nil when the Once fired
259
+ upgradeNextProto map [string ]func (string , * tls.Conn ) upgradableRoundTripper
262
260
263
261
// ForceAttemptHTTP2 controls whether HTTP/2 is enabled when a non-zero
264
262
// Dial, DialTLS, or DialContext func or TLSClientConfig is provided.
@@ -540,10 +538,9 @@ func (t *Transport) roundTrip(req *Request) (*Response, error) {
540
538
resp , err = pconn .alt .RoundTrip (req )
541
539
} else {
542
540
resp , err = pconn .roundTrip (treq )
543
-
544
- if err == nil && resp .StatusCode == StatusSwitchingProtocols {
541
+ if err == nil && resp .isProtocolSwitch () {
545
542
upgradeProto := resp .Header .Get ("Upgrade" )
546
- if upgradeFn , ok := t .UpgradeNextProto [upgradeProto ]; ok {
543
+ if upgradeFn , ok := t .upgradeNextProto [upgradeProto ]; ok {
547
544
t2 := upgradeFn (cm .targetAddr , pconn .conn .(* tls.Conn ))
548
545
pconn .alt = t2
549
546
resp , err = t2 .completeUpgrade (req )
@@ -2154,8 +2151,6 @@ func (pc *persistConn) readResponse(rc requestAndChan, trace *httptrace.ClientTr
2154
2151
break
2155
2152
}
2156
2153
if resp .isProtocolSwitch () {
2157
- // TODO(gerg): This might be an interesting place to put some upgrade logic
2158
-
2159
2154
resp .Body = newReadWriteCloserBody (pc .br , pc .conn )
2160
2155
}
2161
2156
0 commit comments