Skip to content

Commit

Permalink
Let EnableForceHTTP1 also take effect when called when there is alrea…
Browse files Browse the repository at this point in the history
…dy an http2 connection
  • Loading branch information
imroc committed May 17, 2022
1 parent 6dd0386 commit 62efe1e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,16 @@ func (t *Transport) roundTrip(req *http.Request) (*http.Response, error) {
cancelKey := cancelKey{origReq}
req = setupRewindBody(req)

if altRT := t.alternateRoundTripper(req); altRT != nil {
if resp, err := altRT.RoundTrip(req); err != http.ErrSkipAltProtocol {
return resp, err
}
var err error
req, err = rewindBody(req)
if err != nil {
return nil, err
if t.ForceHttpVersion != HTTP1 {
if altRT := t.alternateRoundTripper(req); altRT != nil {
if resp, err := altRT.RoundTrip(req); err != http.ErrSkipAltProtocol {
return resp, err
}
var err error
req, err = rewindBody(req)
if err != nil {
return nil, err
}
}
}
if !isHTTP {
Expand Down Expand Up @@ -576,7 +578,7 @@ func (t *Transport) roundTrip(req *http.Request) (*http.Response, error) {
}

var resp *http.Response
if pconn.alt != nil {
if t.ForceHttpVersion != HTTP1 && pconn.alt != nil {
// HTTP/2 path.
t.setReqCanceler(cancelKey, nil) // not cancelable with CancelRequest
resp, err = pconn.alt.RoundTrip(req)
Expand Down

0 comments on commit 62efe1e

Please sign in to comment.