-
Notifications
You must be signed in to change notification settings - Fork 975
Description
Versions
- httpx: v1.7.1
- retryablehttp-go: v1.0.119
Current Behavior:
If you see httpx repocommon/httpx/httpx.go
156 line
if httpx.Options.Protocol == "http11" {
// disable http2
os.Setenv("GODEBUG", "http2client=0")
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
}
When using HTTP 1.1, change transport, and it will use retryablehttp
But if we see retryablehttp repo do.go
62 line
// 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)
}
This issue is caused by the retry behavior in retryablehttp-go, as discussed in
projectdiscovery/retryablehttp-go#3.
If httpx set client for using only http1.1 but retryable use another client in this case so -pr
does not work correctly.
Expected Behavior:
Use transport change client when httpx -pr
is on
Suggestion
Add Options.DisableHTTPFallback (Example). If set, skip the HTTP/2 fallback (HTTPClient2) on malformed HTTP/2 errors and treat them according to the retry policy.
This respects explicit HTTP/1.1-only configs and avoids unintended protocol switches and policy divergence (proxy/dialer/redirect/TLS)