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 @@ -72,6 +72,10 @@ type Options struct {
//
// If less than or equal to zero, defaults to 1024.
TLSSessionCacheSize int
// DisableHTTP2Fallback disables automatic fallback to HTTP/2 client on malformed HTTP/2 errors.
// When enabled, HTTP/1.x transport errors are handled according to the retry policy
// instead of automatically switching to HTTP/2.
DisableHTTP2Fallback bool
}

// DefaultOptionsSpraying contains the default options for host spraying
Expand Down
3 changes: 2 additions & 1 deletion do.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ 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") {
// unless HTTP/2 fallback is explicitly disabled
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