diff --git a/src/hackney_request.erl b/src/hackney_request.erl index 612a1707..d7059213 100644 --- a/src/hackney_request.erl +++ b/src/hackney_request.erl @@ -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) -> diff --git a/src/hackney_url.erl b/src/hackney_url.erl index bd9c063c..b8466acb 100644 --- a/src/hackney_url.erl +++ b/src/hackney_url.erl @@ -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.