Skip to content

fix: keep the request URL when redirecting to HTTPS - #107

Merged
unrolled merged 1 commit into
unrolled:v1from
SashaMIT:fix/redirect-url-copy
Nov 10, 2026
Merged

unrolled merged 1 commit into
unrolled:v1from
SashaMIT:fix/redirect-url-copy

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An HTTPS redirect assigned r.URL and then changed the scheme and host. The caller still holds that request, so a later check can treat the original HTTP request as HTTPS, or keep the rewritten host. The Location header is now built from a copy, and the caller's URL stays as it arrived.

Test plan

  • go test -count=1 . passes
  • TestSSLRedirectLeavesRequestURL and TestSSLForceHostLeavesRequestURL fail on url := r.URL and pass with the copy

The redirect wrote the new scheme and host through r.URL, so the caller saw its own request rewritten. Copy the URL first.
@unrolled
unrolled merged commit 926ed22 into unrolled:v1 Nov 10, 2026
7 checks passed
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Thanks for merging this. The redirect Location is built from a copy, so the caller's request URL stays on the original scheme and host.

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