Repository navigation
fix: resolve chained redirects against the current URL - #915
Merged
Merged
Conversation
Owner
|
Looks good. Thank you! |
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.
Chained relative redirects resolve against the initial request URL rather than the URL that returned the latest Location header. For example,
/start→/dir/next→leafcurrently requests/leafinstead of/dir/leaf.Pass the current redirect URL into the next redirect step. Compare the destination authority against the generated request URL when updating Host, so subsequent redirects on a different server continue to receive the correct header.
The connection is reused only when both scheme and authority match, so an
http://B→https://Bhop opens a new connection instead of sending the HTTPS request over the HTTP one (unit testconnection_is_reused_only_for_same_scheme_and_authority).Testing and validation
Added an integration test for the chained relative path, covering both a single server and an initial redirect from another authority. The test checks that the final handler receives the request and the expected Host header.
cargo test --test tests test_chained_relative_redirectsfails on master (the final/dir/leafhandler is never reached) and passes with this change; the existingtest_redirectcases still pass andcargo fmt --all -- --checkis clean.AI assistance: this patch and its regression tests were written with AI coding assistance and reviewed before submission.