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 when
// HTTP/1.x transport errors occur. Set this to true when you want
// to enforce strict HTTP/1.1 only mode.
DisableHTTP2Fallback bool
}

// DefaultOptionsSpraying contains the default options for host spraying
Expand Down
9 changes: 6 additions & 3 deletions do.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ 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)
// unless DisableHTTP2Fallback is set (for strict HTTP/1.1 mode)
if !c.options.DisableHTTP2Fallback {
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 err != nil {
Expand Down