Skip to content

feat: add DisableHTTP2Fallback option#524

Closed
jpirstin wants to merge 2 commits intoprojectdiscovery:mainfrom
jpirstin:fix/disable-http2-fallback
Closed

feat: add DisableHTTP2Fallback option#524
jpirstin wants to merge 2 commits intoprojectdiscovery:mainfrom
jpirstin:fix/disable-http2-fallback

Conversation

@jpirstin
Copy link

Summary

Adds a DisableHTTP2Fallback option to Options struct that, when set to true, prevents the automatic fallback to HTTP/2 client (HTTPClient2) when the HTTP/1.x transport encounters malformed HTTP version errors.

Problem

When callers (e.g., httpx with -pr http11) explicitly configure HTTP/1.1-only transport by setting TLSNextProto to an empty map, the fallback in do.go still switches to HTTPClient2 on certain errors, bypassing the caller's explicit protocol choice. This causes the -pr flag in httpx to not work correctly.

Solution

Added a boolean DisableHTTP2Fallback option. When enabled, the HTTP/2 fallback path in do.go is skipped, and errors are handled according to the normal retry policy.

Changes

  • client.go: Added DisableHTTP2Fallback bool to Options struct
  • do.go: Guard the HTTP/2 fallback with !c.options.DisableHTTP2Fallback

Fixes projectdiscovery/httpx#2240

…back

When callers explicitly configure HTTP/1.1 only transport, the automatic
fallback to HTTP/2 client on malformed HTTP version errors should be
skippable. This adds a DisableHTTP2Fallback option that, when set to true,
prevents the fallback to HTTPClient2.

Fixes projectdiscovery/httpx#2240
jpirstin added a commit to jpirstin/httpx that referenced this pull request Feb 16, 2026
…ehttp

When using -pr http11, httpx configures the transport to disable HTTP/2
but retryablehttp-go's automatic fallback to HTTPClient2 on malformed
HTTP version errors bypasses this setting. This sets the new
DisableHTTP2Fallback option in retryablehttp-go when protocol is http11.

Depends on: projectdiscovery/retryablehttp-go#524
Fixes projectdiscovery#2240
@jpirstin
Copy link
Author

Hi team — just flagging that CI workflows are showing action_required (first-time contributor gate). Local go test ./... and go vet ./... both pass cleanly. Could a maintainer approve the workflow run when you get a chance? Thanks 🙏

@jpirstin
Copy link
Author

Friendly ping — this PR adds a DisableHTTP2Fallback option to prevent automatic HTTP/2→HTTP/1.1 downgrade. All local tests pass. The CI checks show action_required (first-time contributor gate). Could a maintainer approve the workflow run when convenient? Thanks 🙏

@jpirstin
Copy link
Author

Checking in on this PR — any feedback or CI gate changes needed to move it forward? Happy to rebase or adjust. Thanks!

@Mzack9999
Copy link
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.

@Mzack9999 Mzack9999 closed this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-pr http11 flag is ignored on retryablehttp-go due to HTTP/2 fallback

2 participants