Skip to content

fix: keep the path on a query-only redirect Location - #1050

Open
NotAFlightRisk wants to merge 1 commit into
benoitc:masterfrom
NotAFlightRisk:fix/redirect-query-only-path
Open

NotAFlightRisk wants to merge 1 commit into
benoitc:masterfrom
NotAFlightRisk:fix/redirect-query-only-path

Conversation

@NotAFlightRisk

Copy link
Copy Markdown

With follow_redirect on, a redirect to a query-only Location like ?page=2 drops the last segment of the path. From /dir/start hackney asks for /dir/?page=2, because the empty path gets merged as if it were a relative one. RFC 3986 keeps the base path when the reference hasn't got one, and its example table in section 5.4.1 has "?y" = "http://a/b/c/d;p?y", so that should be /dir/start?page=2. Relative and absolute paths resolve the same as before.

The new test redirects to ?url=/get, which only gets to /get if it goes back through /redirect-to. It's a 404 without the change, and rebar3 eunit passes with it on OTP 27.

A Location like "?page=2" was merged as if it were a relative path, so
from /dir/start the redirect went to /dir/?page=2. RFC 3986 5.2.2 keeps
the base path when the reference has none, giving /dir/start?page=2.
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.

1 participant