Add H2C fallback to HTTP/1.1 support - #166
Merged
Merged
Conversation
Only when H2C not is supported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refines the handling of HTTP/2 cleartext (h2c) upgrade attempts in
HTTP2JettyClient, ensuring that requests are only retried when the server explicitly refuses the upgrade, and not when it simply ignores the upgrade headers and serves the request over HTTP/1.1. This prevents duplicate requests and potential side effects, and improves efficiency by caching origins that do not support h2c. Comprehensive tests have been added to verify the new behavior.Core logic improvements
H2C_UPGRADE_REFUSED_STATUSES, a set of HTTP status codes (400, 426, 501, 505) that indicate the server refused the h2c upgrade, and updatedshouldRetryAfterFailedH2cUpgradeto only retry requests in these cases instead of retrying whenever HTTP/2 was not negotiated. [1] [2] [3]setHeadersto skip sending h2c upgrade headers to origins already known to be HTTP/1.1-only, preventing unnecessary upgrade attempts and reducing request overhead.Testing enhancements
HTTP2JettyClientH2cFallbackTestto verify that:Test utility improvements
ContentResponseobjects in tests, allowing for direct and reliable verification of retry logic based on different status codes. [1] [2] [3]