Skip to content

fix: respect -pr http11 flag by disabling HTTP/2 fallback - #2389

Closed
erdogan98 wants to merge 1 commit into
projectdiscovery:devfrom
erdogan98:fix/http11-protocol-enforcement
Closed

erdogan98 wants to merge 1 commit into
projectdiscovery:devfrom
erdogan98:fix/http11-protocol-enforcement

Conversation

@erdogan98

@erdogan98 erdogan98 commented Feb 2, 2026 •

Copy link
Copy Markdown

/claim #2240

Summary

This PR fixes the issue where the -pr http11 flag is ignored because retryablehttp-go falls back to HTTP/2 on certain errors.

Problem

When users specify -pr http11 to force HTTP/1.1 only connections:

  1. httpx correctly sets TLSNextProto = map[string]func(){} to disable HTTP/2 on the main transport
  2. However, retryablehttp-go's Client has a separate HTTPClient2 field configured for HTTP/2
  3. When retryablehttp encounters HTTP/1.x errors like malformed HTTP version "HTTP/2", it falls back to HTTPClient2 (see do.go line 62)
  4. This causes the -pr http11 flag to be effectively ignored

Solution

When http11 protocol is explicitly requested, set HTTPClient2 to 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

  • Modified common/httpx/httpx.go: Set HTTPClient2 to use HTTP/1.1-only transport when Protocol == "http11"
  • Added unit test in common/httpx/httpx_test.go to verify HTTP/1.1 enforcement

Testing

  • Unit tests pass
  • Build succeeds

Fixes #2240

Summary by CodeRabbit

  • New Features

    • Added support for enforcing HTTP/1.1 protocol when explicitly configured.
  • Tests

    • Added test coverage to verify HTTP/1.1 protocol enforcement behavior and default protocol handling.

…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
@coderabbitai

coderabbitai Bot commented Feb 2, 2026 •

Copy link
Copy Markdown

Walkthrough

The 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

Cohort / File(s) Summary
HTTP/1.1 Protocol Enforcement
common/httpx/httpx.go
Adds conditional block that configures HTTPClient2 with HTTP/1.1-only transport when Protocol is set to "http11", disabling the HTTP/2 fallback mechanism in retryablehttp.
Protocol Enforcement Test
common/httpx/httpx_test.go
Adds TestHTTP11ProtocolEnforcement test with subtests validating that http11 mode disables HTTP/2 (TLSNextProto empty) while default mode allows HTTP/2.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A fix for the protocol that wouldn't stay,
When HTTP/1.1 was the chosen way,
We tie the fallback to match the main,
No sneaky HTTP/2 will cause us pain,
One protocol rules them, that's here to stay! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: respecting the http11 flag by disabling HTTP/2 fallback in retryablehttp.
Linked Issues check ✅ Passed The pull request successfully addresses issue #2240 by setting HTTPClient2 to use the HTTP/1.1-only transport when Protocol='http11', ensuring all retry paths respect the enforced protocol.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the HTTP/1.1 protocol enforcement issue; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dogancanbakir
dogancanbakir requested review from dogancanbakir and removed request for Mzack9999 February 3, 2026 15:43
@dogancanbakir

Copy link
Copy Markdown
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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