Skip to content

Commit

Permalink
Follow HTTP 308 redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed Oct 11, 2021
1 parent c8f3a6c commit 2045c64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/hackney.erl
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ maybe_redirect(
case redirect_location(Headers) of
undefined -> Resp;
Location ->
IsRedirect = lists:member(S, [301, 302, 303, 307]),
IsRedirect = lists:member(S, [301, 302, 303, 307, 308]),
case IsRedirect of
false -> Resp;
_ ->
Expand All @@ -734,7 +734,7 @@ maybe_redirect(
end
end;
maybe_redirect({ok, S, _H, #client{follow_redirect=true}}=Resp, _Req) ->
case lists:member(S, [301, 302, 303, 307]) of
case lists:member(S, [301, 302, 303, 307, 308]) of
true ->
{error, {max_redirect_overflow, Resp}};
false ->
Expand All @@ -746,7 +746,7 @@ maybe_redirect(Resp, _Req) ->

maybe_redirect1(Location, {ok, S, H, #client{retries=Tries}=Client}=Resp, Req) ->
{Method, _Path, Headers, Body} = Req,
case lists:member(S, [301, 302, 307]) of
case lists:member(S, [301, 302, 307, 308]) of
true ->
?report_debug("redirect request", [{location, Location},
{req, Req},
Expand Down
2 changes: 1 addition & 1 deletion src/hackney_stream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ maybe_redirect(Parent, Owner, Ref, StatusInt, Reason,
socket=Socket,
method=Method,
follow_redirect=true}=Client) ->
case lists:member(StatusInt, [301, 302, 307]) of
case lists:member(StatusInt, [301, 302, 307, 308]) of
true ->
Transport:setopts(Socket, [{active, false}]),
case parse(Client) of
Expand Down

0 comments on commit 2045c64

Please sign in to comment.