Skip to content

fix: resolve chained redirects against the current URL - #915

Merged
hatoo merged 1 commit into
hatoo:masterfrom
pcbeingused333:fix/c3723-relative-redirects
Nov 18, 2026
Merged

hatoo merged 1 commit into
hatoo:masterfrom
pcbeingused333:fix/c3723-relative-redirects

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Chained relative redirects resolve against the initial request URL rather than the URL that returned the latest Location header. For example, /start → /dir/next → leaf currently requests /leaf instead 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://B hop opens a new connection instead of sending the HTTPS request over the HTTP one (unit test connection_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_redirects fails on master (the final /dir/leaf handler is never reached) and passes with this change; the existing test_redirect cases still pass and cargo fmt --all -- --check is clean.

AI assistance: this patch and its regression tests were written with AI coding assistance and reviewed before submission.

@hatoo

hatoo commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Looks good. Thank you!

@hatoo
hatoo merged commit 780c4e6 into hatoo:master Nov 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants