Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ type Options struct {
Backoff Backoff
// NoAdjustTimeout disables automatic adjustment of HTTP request timeout
NoAdjustTimeout bool
// DisableHTTP2Fallback disables automatic fallback to HTTP/2 when HTTP/1.x
// transport encounters malformed HTTP version errors. This should be set
// when the caller explicitly wants HTTP/1.1 only.
DisableHTTP2Fallback bool
// Custom http client
HttpClient *http.Client
// WrapTransport wraps the underlying [http.RoundTripper].
Expand Down
2 changes: 1 addition & 1 deletion do.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
checkOK, checkErr := c.CheckRetry(req.Context(), resp, err)

// if err is equal to missing minor protocol version retry with http/2
if err != nil && stringsutil.ContainsAny(err.Error(), "net/http: HTTP/1.x transport connection broken: malformed HTTP version \"HTTP/2\"", "net/http: HTTP/1.x transport connection broken: malformed HTTP response") {
if !c.options.DisableHTTP2Fallback && err != nil && stringsutil.ContainsAny(err.Error(), "net/http: HTTP/1.x transport connection broken: malformed HTTP version \"HTTP/2\"", "net/http: HTTP/1.x transport connection broken: malformed HTTP response") {
resp, err = c.HTTPClient2.Do(req.Request)
checkOK, checkErr = c.CheckRetry(req.Context(), resp, err)
}
Expand Down