Skip to content

Commit 3494fcc

Browse files
committed
Favor private types/fields
- Switch `upgradableRoundTripper` and `upgradeNextProto` to be private. We can always change these to be public if/when we move logic into another package. [cloudfoundry/routing-release#200]
1 parent bf440db commit 3494fcc

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

http/h2_bundle.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

http/transport.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ type Transport struct {
230230
// automatically.
231231
TLSNextProto map[string]func(authority string, c *tls.Conn) RoundTripper
232232

233-
// TODO(gerg): Consider this public interface change for Transport
234-
UpgradeNextProto map[string]func(string, *tls.Conn) UpgradableRoundTripper
235-
236233
// ProxyConnectHeader optionally specifies headers to send to
237234
// proxies during CONNECT requests.
238235
ProxyConnectHeader Header
@@ -259,6 +256,7 @@ type Transport struct {
259256
nextProtoOnce sync.Once
260257
h2transport h2Transport // non-nil if http2 wired up
261258
tlsNextProtoWasNil bool // whether TLSNextProto was nil when the Once fired
259+
upgradeNextProto map[string]func(string, *tls.Conn) upgradableRoundTripper
262260

263261
// ForceAttemptHTTP2 controls whether HTTP/2 is enabled when a non-zero
264262
// Dial, DialTLS, or DialContext func or TLSClientConfig is provided.
@@ -540,10 +538,9 @@ func (t *Transport) roundTrip(req *Request) (*Response, error) {
540538
resp, err = pconn.alt.RoundTrip(req)
541539
} else {
542540
resp, err = pconn.roundTrip(treq)
543-
544-
if err == nil && resp.StatusCode == StatusSwitchingProtocols {
541+
if err == nil && resp.isProtocolSwitch() {
545542
upgradeProto := resp.Header.Get("Upgrade")
546-
if upgradeFn, ok := t.UpgradeNextProto[upgradeProto]; ok {
543+
if upgradeFn, ok := t.upgradeNextProto[upgradeProto]; ok {
547544
t2 := upgradeFn(cm.targetAddr, pconn.conn.(*tls.Conn))
548545
pconn.alt = t2
549546
resp, err = t2.completeUpgrade(req)
@@ -2154,8 +2151,6 @@ func (pc *persistConn) readResponse(rc requestAndChan, trace *httptrace.ClientTr
21542151
break
21552152
}
21562153
if resp.isProtocolSwitch() {
2157-
// TODO(gerg): This might be an interesting place to put some upgrade logic
2158-
21592154
resp.Body = newReadWriteCloserBody(pc.br, pc.conn)
21602155
}
21612156

0 commit comments

Comments
 (0)