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
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Client struct {
Backoff Backoff

options Options
DisableHTTPFallback bool
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should be aligned to the left (if you use vscode or cursor it should automatically fmt on file save)

}

// Options contains configuration options for the client
Expand Down
11 changes: 8 additions & 3 deletions do.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ 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") {
resp, err = c.HTTPClient2.Do(req.Request)
checkOK, checkErr = c.CheckRetry(req.Context(), resp, err)
if !c.DisableHTTPFallback &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can control this at package level with something like:

var ENABLE_HTTP2 = true

with default value to true, so that users can disable it via code. What do you think?

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)
}

if err != nil {
Expand Down
Loading