Repository navigation
Conversation
…ehttp When the -pr http11 flag is used to force HTTP/1.1 only connections, the retryablehttp client's HTTPClient2 was still configured to use HTTP/2. This caused unexpected fallback to HTTP/2 when retryablehttp encountered certain HTTP/1.x errors (like 'malformed HTTP version HTTP/2'). The fix sets HTTPClient2 to use the same HTTP/1.1-only transport when http11 protocol is explicitly requested, ensuring the protocol preference is respected throughout the entire request lifecycle. Fixes projectdiscovery#2240
WalkthroughThe pull request adds conditional logic to enforce HTTP/1.1-only connections by configuring the HTTPClient2 fallback client with the same HTTP/1.1 transport settings when the Protocol option is explicitly set to "http11". This prevents retryablehttp from unexpectedly switching to HTTP/2 on connection errors. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, thanks for your interest in contributing! Just a heads up, we ask contributors to work on 1 active issue at a time (see). Also, we welcome AI-assisted development, but submissions must be complete, tested, and ready to merge. Please also make sure to fill out the PR template with proof that your changes work. We're closing this PR along with your other open submissions. Once you're ready, feel free to pick one issue to focus on and resubmit; we'd be happy to review it. Appreciate your understanding! |
/claim #2240
Summary
This PR fixes the issue where the
-pr http11flag is ignored because retryablehttp-go falls back to HTTP/2 on certain errors.Problem
When users specify
-pr http11to force HTTP/1.1 only connections:TLSNextProto = map[string]func(){}to disable HTTP/2 on the main transportClienthas a separateHTTPClient2field configured for HTTP/2malformed HTTP version "HTTP/2", it falls back toHTTPClient2(see do.go line 62)-pr http11flag to be effectively ignoredSolution
When
http11protocol is explicitly requested, setHTTPClient2to use the same HTTP/1.1-only transport. This ensures the protocol preference is respected throughout the entire request lifecycle, including during retryablehttp's error handling.Changes
common/httpx/httpx.go: SetHTTPClient2to use HTTP/1.1-only transport whenProtocol == "http11"common/httpx/httpx_test.goto verify HTTP/1.1 enforcementTesting
Fixes #2240
Summary by CodeRabbit
New Features
Tests