fix: add DisableHTTP2Fallback option to respect HTTP/1.1-only transport configs#532
Closed
usernametooshort wants to merge 1 commit intoprojectdiscovery:mainfrom
Closed
Conversation
When a caller explicitly sets HTTP/1.1-only transport (e.g. httpx -pr http11), retryablehttp-go's automatic HTTP/2 fallback in do.go would silently bypass this restriction. This introduces DisableHTTP2Fallback in Options which, when set, skips the HTTPClient2.Do fallback on malformed HTTP/2 errors. Fixes the underlying cause of projectdiscovery/httpx#2240.
Neo - PR Security ReviewNo security issues found Highlights
Comment |
usernametooshort
added a commit
to usernametooshort/httpx
that referenced
this pull request
Mar 6, 2026
… 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: projectdiscovery#2240
usernametooshort
added a commit
to usernametooshort/httpx
that referenced
this pull request
Mar 6, 2026
… 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: projectdiscovery#2240
Member
|
The underlying issue (httpx#2240) has been resolved at the httpx level — the HTTP/1.1 protocol preference is now correctly enforced without requiring changes to retryablehttp-go. Closing as the original bounty issue is already complete. Thanks for the contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a caller explicitly configures HTTP/1.1-only transport (e.g.
httpx -pr http11which setstransport.TLSNextProto = map[string]func(...){}andGODEBUG=http2client=0), retryablehttp-go silently bypasses this restriction via the automatic HTTP/2 fallback indo.go:This means
-pr http11in httpx has no effect for servers that respond with HTTP/2.See: projectdiscovery/httpx#2240
Fix
Add
DisableHTTP2Fallback booltoOptions. When set, theHTTPClient2.Dofallback is skipped, respecting the caller's explicit protocol choice.Usage (httpx side)
In httpx when
Protocol == "http11":This is a non-breaking change — existing callers that do not set the option retain the current fallback behavior.