Skip to content

Commit

Permalink
hackney_request:location/1 should return an absolute url
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Oct 9, 2023
1 parent 250cdbb commit f690611
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/hackney_request.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ location(Client) ->
Url = #hackney_url{scheme=Scheme, netloc=Netloc, path=Path},
hackney_url:unparse_url(Url);
Location ->
Location
case hackney_url:parse_url(Location) of
#hackney_url{netloc = <<>>} ->
Scheme = hackney_url:transport_scheme(Transport),
Url = #hackney_url{scheme=Scheme, netloc=Netloc, path=Location},
hackney_url:unparse_url(Url);
_ ->
Location
end
end.

stream_body(Msg, #client{expect=true}=Client) ->
Expand Down
3 changes: 2 additions & 1 deletion src/hackney_url.erl
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ parse_netloc(Netloc, #hackney_url{transport=Transport}=S) ->
port=0};
[Host, Port] ->
S#hackney_url{host=unicode:characters_to_list(Host),
port=list_to_integer(binary_to_list(Port))}
port=list_to_integer(binary_to_list(Port))};
[] -> S
end.


Expand Down

0 comments on commit f690611

Please sign in to comment.