Skip to content

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

Closed

Description

@khs-alt

Versions

  • httpx: v1.7.1
  • retryablehttp-go: v1.0.119

Current Behavior:

If you see httpx repocommon/httpx/httpx.go 156 line

	if httpx.Options.Protocol == "http11" {
		// disable http2
		os.Setenv("GODEBUG", "http2client=0")
		transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
	}

When using HTTP 1.1, change transport, and it will use retryablehttp
But if we see retryablehttp repo do.go 62 line

		// if err is equal to missing minor protocol version retry with http/2
		if err != nil && stringsutil.ContainsAny(err.Error(), "net/http: HTTP/1.x transport connection broken: malformed HTTP version \"HTTP/2\"", "net/http: HTTP/1.x transport connection broken: malformed HTTP response") {
			resp, err = c.HTTPClient2.Do(req.Request)
			checkOK, checkErr = c.CheckRetry(req.Context(), resp, err)
		}

This issue is caused by the retry behavior in retryablehttp-go, as discussed in
projectdiscovery/retryablehttp-go#3.
If httpx set client for using only http1.1 but retryable use another client in this case so -pr does not work correctly.

Expected Behavior:

Use transport change client when httpx -pr is on

Suggestion

Add Options.DisableHTTPFallback (Example). If set, skip the HTTP/2 fallback (HTTPClient2) on malformed HTTP/2 errors and treat them according to the retry policy.
This respects explicit HTTP/1.1-only configs and avoids unintended protocol switches and policy divergence (proxy/dialer/redirect/TLS)

Activity

  1. added
    Type: Bug
    on Aug 13, 2025
  2. dogancanbakir commented on Feb 2, 2026

    @dogancanbakir
    Member

    /bounty $100

  3. algora-pbc commented on Feb 2, 2026

    @algora-pbc

    💎 $100 bounty • ProjectDiscovery Bounty Available

    How to Participate:

    • Claim attempt: Comment /attempt #2240 on this issue. Multiple participants can attempt, but only the first to submit a complete, mergeable solution will receive the reward.
    • Work on the issue: Follow the Contribution Guidelines and ensure your solution fully addresses the issue requirements.
    • Submit your PR: Open a pull request to projectdiscovery/httpx and include /claim #2240 in the PR body.
    • Receive payment: Upon successful merge, you will receive 100% of the bounty through Algora within 2-5 days.

    Thank you for contributing to projectdiscovery/httpx and helping us democratize security!


    PR Requirements

    Your PR must include the following. PRs that don't meet these requirements may not be reviewed and could be closed.

    Proposed Changes

    Describe the overall picture of your modifications to help maintainers understand the pull request.

    Proof

    Demonstrate your changes work. Include before/after examples, screenshots, or terminal output showing the fix/feature in action.

    Checklist

    • PR created against the correct branch (usually dev)
    • All checks passed (lint, unit/integration/regression tests)
    • Tests added that prove the fix is effective or feature works
    • Documentation added (if appropriate)

    Add a bounty • Share on socials

    Attempt Started (UTC) Solution Actions
    🟢 @danagrozav98-design Mar 02, 2026, 08:56:36 AM WIP
    🟢 @erdogan98 Feb 02, 2026, 06:11:09 PM #2389 Reward
    🟢 @umer12-12 Mar 03, 2026, 02:27:46 AM #2428 Reward
    🟢 @khs-alt Feb 03, 2026, 01:05:33 PM WIP
    🟢 @hetbhatt2807 Mar 04, 2026, 07:44:27 AM WIP
    🟢 @MAVRICK-1 Feb 04, 2026, 07:31:42 AM #2392 Reward
    🟢 @juzigu40-ui Mar 04, 2026, 11:26:26 AM #2421 Reward
    🟢 @justinleeyang Mar 05, 2026, 04:27:59 PM WIP
    🟢 @Tianlin0725 Mar 05, 2026, 06:02:59 PM #2437 Reward
    🟢 @ck3960250 Mar 05, 2026, 09:24:21 PM #2441 Reward
    🟢 @thecafetron-ctrl Feb 07, 2026, 05:26:15 PM #2395 Reward
    🟢 @innerpeace609 Mar 09, 2026, 09:04:49 PM #2448 Reward
    🟢 @ashuwhy Feb 12, 2026, 01:21:33 PM WIP
    🟢 @nenadilic84 Feb 14, 2026, 12:07:40 PM WIP
    🟢 @285729101 Feb 17, 2026, 02:36:18 AM #2408 Reward
    🟢 @drmabus Mar 19, 2026, 08:01:02 AM #2456 Reward
    🟢 @chengyixu Mar 19, 2026, 10:17:33 AM WIP
    🟢 @ Feb 20, 2026, 12:49:00 PM WIP
    🟢 @cococlaw Feb 20, 2026, 06:05:44 PM #2414 Reward
    🟢 @wh0amibjm Feb 20, 2026, 08:23:18 PM #2416 Reward
    🟢 @shukwei899 Feb 20, 2026, 08:08:22 PM #2415 Reward
    🟢 @Bushi-gg Feb 24, 2026, 11:51:51 PM #2420 Reward
    🟢 @Veirt Feb 27, 2026, 06:57:00 PM #2424 Reward
    🟢 @teredasites Feb 27, 2026, 07:50:30 PM #2425 Reward
    🟢 @SolariSystems Feb 28, 2026, 04:51:44 PM #2419 Reward
  4. 1234-ad commented on Feb 2, 2026

    @1234-ad

    Fix Submitted! 🎉

    I've analyzed the issue and submitted a comprehensive fix across two repositories:

    Root Cause

    The -pr http11 flag was being ignored because:

    1. httpx correctly disables HTTP/2 in the main client
    2. retryablehttp-go automatically falls back to HTTP/2 on certain errors, bypassing httpx's configuration

    Solution

    PR #521 to retryablehttp-go: projectdiscovery/retryablehttp-go#521

    • Adds DisableHTTP2 option to prevent automatic HTTP/2 fallback
    • Fully backward compatible (disabled by default)

    PR #2387 to httpx: #2387

    • Sets DisableHTTP2 = true when -pr http11 is specified
    • Includes complete documentation and implementation guide

    The Fix (5 lines of code)

    In common/httpx/httpx.go, after line 79:

    // Disable HTTP/2 fallback when http11 protocol is explicitly requested
    if httpx.Options.Protocol == "http11" {
    	retryablehttpOptions.DisableHTTP2 = true
    }

    Testing

    Before:

    $ httpx -u https://example.com -pr http11
    # HTTP/2 used despite flag ❌

    After:

    $ httpx -u https://example.com -pr http11  
    # Only HTTP/1.1 used ✅

    Benefits

    ✅ Honors user intent
    ✅ Backward compatible
    ✅ Clean solution
    ✅ Well documented

    Both PRs are ready for review!

  5. added a commit that references this issue on Feb 2, 2026
    fabbaea
  6. dogancanbakir commented on Feb 3, 2026

    @dogancanbakir
    Member

    Hey contributors! Please make sure your PR follows the PR template and includes proof that your changes work (before/after examples, screenshots, or terminal output). Reviewer time is limited! Incomplete PRs may be closed without review. Thanks!

  7. khs-alt commented on Feb 3, 2026

    @khs-alt
    ContributorAuthor

    /attempt #2240

  8. thecafetron-ctrl commented on Feb 7, 2026

    @thecafetron-ctrl

    /attempt #2240

  9. thecafetron-ctrl commented on Feb 7, 2026

    @thecafetron-ctrl

    Implemented fix + PR opened:

    Proof:

    • Offline tests (no external network):

    /claim #2240

  10. 45 remaining items

  11. Tianlin0725 commented on Mar 6, 2026

    @Tianlin0725

    /attempt #2240
    Plan: reproduce being ignored on retry fallback, enforce protocol pinning across retries, add a regression test to ensure no HTTP/2 fallback when http11 is requested, then submit PR with /claim #2240.

  12. Tianlin0725 commented on Mar 6, 2026

    @Tianlin0725

    /attempt #2240
    Plan: reproduce the http11 protocol flag being ignored on retry fallback, enforce protocol pinning across retries, add a regression test to ensure no HTTP/2 fallback when http11 is requested, then submit PR with /claim #2240.

  13. ck3960250 commented on Mar 7, 2026

    @ck3960250

    /attempt #2240

    Merge-first plan:

    1. Keep explicit -pr http11 behavior by preventing retry fallback from switching to HTTP/2 client.
    2. Add a focused unit test to lock behavior (HTTPClient2 == HTTPClient in http11 mode).
    3. Open narrow PR with proof from targeted test run.
  14. ck3960250 commented on Mar 7, 2026

    @ck3960250

    PR opened: #2441

    Includes /claim #2240, narrow fix, and regression test.

  15. innerpeace609 commented on Mar 9, 2026

    @innerpeace609

    /attempt #2240

  16. drmabus commented on Mar 19, 2026

    @drmabus

    PR #2456 implements a complete fix for this issue.

    It ensures that when -pr http11 is specified, HTTP/1.1 is strictly enforced and no HTTP/2 fallback occurs during retryablehttp transport errors.

    This resolves the unintended protocol downgrade by reusing the HTTP/1.1-only client across retries.

    Closes #2240

  17. chengyixu commented on Mar 19, 2026

    @chengyixu

    /attempt #2240

    Implementation Plan: Fix -pr http11 Flag Being Ignored Due to HTTP/2 Fallback

    Problem

    When httpx is configured with -pr http11 (HTTP/1.1 only), retryablehttp-go silently falls back to HTTP/2 via HTTPClient2 when it encounters malformed HTTP/2 errors. This defeats the explicit protocol restriction.

    Root Cause

    In retryablehttp-go/do.go line 62, when an HTTP/1.1 request fails with a malformed HTTP/2 error, the code unconditionally retries with c.HTTPClient2 regardless of whether the caller explicitly restricted to HTTP/1.1.

    Fix

    1. Add DisableHTTPFallback option to retryablehttp-go:

      • New field in retryablehttp.Options: DisableHTTPFallback bool
      • When set to true, skip the HTTP/2 fallback in do.go and treat the error according to normal retry policy
      • This is the cleanest fix as suggested by the issue reporter
    2. Wire it up in httpx:

      • In common/httpx/httpx.go, when Options.Protocol == "http11", also set DisableHTTPFallback: true on the retryablehttp client
      • This ensures the -pr flag is fully respected
    3. Files to modify:

      • retryablehttp-go: options.go (add field), do.go (check flag before fallback)
      • httpx: common/httpx/httpx.go (set flag when protocol is restricted)
    4. Testing:

      • Test with a server that responds with HTTP/2 when HTTP/1.1 is requested
      • Verify no fallback occurs with -pr http11
      • Before/after terminal output proof

    Will submit PR against dev branch.

  18. algora-pbc commented on Mar 19, 2026

    @algora-pbc

    @Veirt: You've been awarded a $100 by ProjectDiscovery! 👉 Complete your Algora onboarding to collect the bounty.

  19. algora-pbc commented on Mar 19, 2026

    @algora-pbc

    🎉🎈 @Veirt has been awarded $100 by ProjectDiscovery! 🎈🎊

  20. zhaog100 commented on Mar 19, 2026

    @zhaog100

    /attempt

    I'll look into the http11 flag being ignored due to HTTP/2 fallback.

  21. Nikolias-Ai commented on Mar 21, 2026

    @Nikolias-Ai

    Hi - I reviewed "pr http11 flag is ignored on retryablehttp-go due to HTTP/2 fallback" and prepared a reviewready draft with reproduction notes and a clear scope (targeting the exact behavior in #2240). This gives you something concrete to validate immediately, rather than a vague pitch.

    Problem summary (current draft): the -pr http11 flag is ignored when retryablehttp-go falls back to HTTP/2, creating unexpected protocol behavior. The draft focuses on reproducible steps, expected vs. actual behavior, and the minimum conditions needed to trigger the fallback.

    What I'll build next:

    • Tighten the reproduction steps into a short, copypasteable flow.
    • Validate edge cases (clean session, consistent fallback behavior).
    • Package the report for a clear bounty review and quick triage.

    Timeline:

    • Day 1: reviewready draft + reproduction flow refined
    • Day 2: polish + submissionready package

    Credibility: I've delivered similar security writeups, including a working prototype artifact showing execution readiness, and I prioritize reproducibility and scoped fixes. I'll route through Github_Bounties and keep everything tight and testable.

    If you want me to proceed, send any constraints (env details, preferred format, or expected impact framing), and I'll tighten the draft immediately.

    Quick review checklist (for your input):

    • Scope accurate to the issue?

    • Repro steps clear enough to run in one pass?

    • Expected vs. actual behavior stated plainly?

    • Any extra edge cases to include?

    • Nicholas C. (Queenstown, New Zealand)

    I already have a working draft prepared and can refine it quickly if you'd like me to proceed.

  22. Nikolias-Ai commented on Mar 26, 2026

    @Nikolias-Ai

    Hi - I reviewed "pr http11 flag is ignored on retryablehttp-go due to HTTP/2 fallback" and prepared a reviewready draft with reproduction notes and a clear scope (targeting the exact behavior in #2240). This gives you something concrete to validate immediately, rather than a vague pitch.

    Problem summary (current draft): the -pr http11 flag is ignored when retryablehttp-go falls back to HTTP/2, creating unexpected protocol behavior. The draft focuses on reproducible steps, expected vs. actual behavior, and the minimum conditions needed to trigger the fallback.

    What I'll build next:

    • Tighten the reproduction steps into a short, copypasteable flow.
    • Validate edge cases (clean session, consistent fallback behavior).
    • Package the report for a clear bounty review and quick triage.

    Timeline:

    • Day 1: reviewready draft + reproduction flow refined
    • Day 2: polish + submissionready package

    Credibility: I've delivered similar security writeups, including a working prototype artifact showing execution readiness, and I prioritize reproducibility and scoped fixes. I'll route through Github_Bounties and keep everything tight and testable.

    If you want me to proceed, send any constraints (env details, preferred format, or expected impact framing), and I'll tighten the draft immediately.

    Quick review checklist (for your input):

    • Scope accurate to the issue?

    • Repro steps clear enough to run in one pass?

    • Expected vs. actual behavior stated plainly?

    • Any extra edge cases to include?

    • Nicholas C. (Queenstown, New Zealand)

    I already have a working draft prepared and can refine it quickly if you'd like me to proceed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    $100Type: Bug💎 Bounty💰 Rewarded

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions