Skip to content

refactor: respect disabled HTTP/2 during retries#523

Closed
AliakbarArshadi wants to merge 1 commit intoprojectdiscovery:mainfrom
AliakbarArshadi:fix-http2-fallback-2240
Closed

refactor: respect disabled HTTP/2 during retries#523
AliakbarArshadi wants to merge 1 commit intoprojectdiscovery:mainfrom
AliakbarArshadi:fix-http2-fallback-2240

Conversation

@AliakbarArshadi
Copy link

This PR fixes the issue where retryablehttp would ignore user-forced HTTP/1.1 settings and incorrectly fall back to HTTP/2 during retries.

Fixes #2240

Proposed changes

  • Added isHTTP2Disabled() method to detect protocol restrictions via GODEBUG=http2client=0 or empty TLSNextProto maps.
  • Modified do.go to skip the HTTPClient2 fallback if HTTP/2 is disabled.
  • Ensured that original error propagates correctly when fallback is disabled.

Proof

  • Added TestClient_HTTP2Fallback_Disabled covering:
    • Successful block of fallback when TLSNextProto is empty.
    • Successful block of fallback when GODEBUG is set.
    • Verification that normal fallback still works when no restrictions are present.
  • All tests passed successfully via go test -v ./....

Checklist

  • Pull request is created against the target branch
  • All checks passed with my changes
  • I have added tests that prove my fix is effective

- Implemented isHTTP2Disabled check to detect GODEBUG and TLSNextProto settings.
- Prevented automatic fallback to HTTPClient2 when HTTP/2 is explicitly disabled.
- Added comprehensive regression tests for protocol restriction scenarios.

Fixes #2240
@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.

2 participants