Skip to content

Conversation

@thecafetron-ctrl
Copy link

@thecafetron-ctrl thecafetron-ctrl commented Feb 9, 2026

Problem

/claim #2240

When running httpx with -pr http11, the transport is configured for HTTP/1.1, but retryablehttp-go can still fall back to an HTTP/2 client on certain error paths. That bypasses the user’s explicit protocol selection and makes -pr http11 unreliable.

Proposed Changes

  • Pin retryablehttp protocol fallback
    • When Options.Protocol == http11, set retryablehttpClient.HTTPClient2 = retryablehttpClient.HTTPClient so the library cannot switch to a different protocol.
  • Tests
    • Keep tests fully offline by using httptest servers (no external network).

Proof

GOCACHE=/tmp/gocache-httpx go test ./common/httpx -count=1

Checklist

  • PR created against the correct branch (dev)
  • Tests added/updated and run locally
  • Proof command included

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Walkthrough

The pull request fixes an issue where the HTTP/1.1 protocol flag was being bypassed by retryablehttp's HTTP/2 fallback mechanism. When HTTP/1.1 is configured, the code now assigns the HTTPClient2 fallback client to the same underlying client as HTTPClient, preventing unintended protocol switching. Tests are added to verify this behavior.

Changes

Cohort / File(s) Summary
HTTP Client Configuration
common/httpx/httpx.go
Added logic to disable HTTP/2 fallback in retryablehttp by assigning HTTPClient2 to HTTPClient when Protocol option is set to "http11", ensuring the HTTP/1.1 protocol flag is respected.
Test Coverage
common/httpx/httpx_test.go
Added new test TestHTTP11DisablesHTTP2Fallback to verify HTTP/2 fallback is disabled when HTTP/1.1 is configured. Updated existing content-length test to use httptest server with controlled response headers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through protocol lands,
Where HTTP/1.1 now firmly stands,
No sneaky HTTP/2 shall bypass its way,
The fallback is caged—hooray, hooray!
With tests that verify each request's flight,
The protocol reigns true and right. 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: disabling HTTP/2 fallback in retryablehttp when HTTP/1.1 protocol is explicitly selected.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #2240: when Protocol == 'http11', it disables HTTP/2 fallback by setting HTTPClient2 to the same HTTPClient, preventing unintended protocol switching.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the issue requirements: httpx.go modifies HTTP/1.1 protocol handling, and httpx_test.go adds tests to verify the fix and improves offline test coverage.

✏️ 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

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
common/httpx/httpx_test.go (1)

51-61: Test correctly validates the HTTP/2 fallback prevention invariant.

require.Same checks pointer identity, which is exactly the right assertion here — confirming that HTTPClient2 is not a separate HTTP/2-capable client but the same HTTP/1.1 client.

Consider adding a complementary test that verifies the default case (without http11) where HTTPClient and HTTPClient2 are not the same, to guard against a future regression that accidentally always sets them equal.


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.

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.

2 participants