Skip to content

Commit 3f038ef

Browse files
fix(-pr http11): disable HTTP/2 fallback in retryablehttp when http11 protocol is set
When -pr http11 is used, httpx correctly sets TLSNextProto={} and GODEBUG=http2client=0 to force HTTP/1.1. However retryablehttp-go's automatic HTTP/2 fallback in do.go silently bypasses this: if err is malformed HTTP/2 response { resp, err = c.HTTPClient2.Do(req.Request) // <- ignores http11 config } This commit sets retryablehttpOptions.DisableHTTP2Fallback=true when Protocol=="http11", ensuring the HTTP/1.1-only requirement is honoured end-to-end. Depends on: projectdiscovery/retryablehttp-go#532 Fixes: #2240
1 parent 4a09273 commit 3f038ef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

common/httpx/httpx.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,13 @@ func New(options *Options) (*HTTPX, error) {
154154
}
155155

156156
if httpx.Options.Protocol == "http11" {
157-
// disable http2
157+
// disable http2 at transport level
158158
_ = os.Setenv("GODEBUG", "http2client=0")
159159
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
160+
// also disable the HTTP/2 fallback in retryablehttp-go so that
161+
// malformed-HTTP/2 errors do not cause a silent protocol upgrade
162+
// via HTTPClient2 (see projectdiscovery/retryablehttp-go#532)
163+
retryablehttpOptions.DisableHTTP2Fallback = true
160164
}
161165

162166
if httpx.Options.SniName != "" {

0 commit comments

Comments
 (0)