func (*http2Transport) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
func (*http2Transport) CloseIdleConnections() {}
-type http2erringRoundTripper struct{}
+type http2erringRoundTripper struct{ err error }
func (http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
}
// Failed. Clean up and determine whether to retry.
-
- _, isH2DialError := pconn.alt.(http2erringRoundTripper)
- if http2isNoCachedConnError(err) || isH2DialError {
+ if http2isNoCachedConnError(err) {
if t.removeIdleConn(pconn) {
t.decConnsPerHost(pconn.cacheKey)
}
- }
- if !pconn.shouldRetryRequest(req, err) {
+ } else if !pconn.shouldRetryRequest(req, err) {
// Issue 16465: return underlying net.Conn.Read error from peek,
// as we've historically done.
if e, ok := err.(transportReadFromServerError); ok {
if s := pconn.tlsState; s != nil && s.NegotiatedProtocolIsMutual && s.NegotiatedProtocol != "" {
if next, ok := t.TLSNextProto[s.NegotiatedProtocol]; ok {
- return &persistConn{t: t, cacheKey: pconn.cacheKey, alt: next(cm.targetAddr, pconn.conn.(*tls.Conn))}, nil
+ alt := next(cm.targetAddr, pconn.conn.(*tls.Conn))
+ if e, ok := alt.(http2erringRoundTripper); ok {
+ // pconn.conn was closed by next (http2configureTransport.upgradeFn).
+ return nil, e.err
+ }
+ return &persistConn{t: t, cacheKey: pconn.cacheKey, alt: alt}, nil
}
}