Skip to content

Commit

Permalink
Send hackney_response before calling handle_error (#573)
Browse files Browse the repository at this point in the history
As hackney_manager:handle_error could terminate the request, the request
process should send the response to the owner before calling it.
  • Loading branch information
Kuroneer authored and benoitc committed Sep 23, 2019
1 parent 9c3f578 commit b4a48ed
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/hackney_stream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ stream_loop(Parent, Owner, Ref, #client{transport=Transport,
Transport:controlling_process(Socket, Parent),
Owner ! {hackney_response, Ref, done};
{error, _Reason} = Error ->
hackney_manager:handle_error(Client),
Owner ! {hackney_response, Ref, Error}
Owner ! {hackney_response, Ref, Error},
hackney_manager:handle_error(Client)
end.

maybe_continue(Parent, Owner, Ref, #client{transport=Transport,
Expand Down Expand Up @@ -196,8 +196,8 @@ maybe_redirect(Parent, Owner, Ref, StatusInt, Reason,
end
end;
{error, Error} ->
hackney_manager:handle_error(Client),
Owner ! {hackney_response, Ref, {error, Error}}
Owner ! {hackney_response, Ref, {error, Error}},
hackney_manager:handle_error(Client)
end;
false when StatusInt =:= 303, Method =:= post ->
Transport:setopts(Socket, [{active, false}]),
Expand All @@ -223,8 +223,8 @@ maybe_redirect(Parent, Owner, Ref, StatusInt, Reason,
end
end;
{error, Error} ->
hackney_manager:handle_error(Client),
Owner ! {hackney_response, Ref, {error, Error}}
Owner ! {hackney_response, Ref, {error, Error}},
hackney_manager:handle_error(Client)
end;
_ ->
Owner ! {hackney_response, Ref, {status, StatusInt, Reason}},
Expand Down

0 comments on commit b4a48ed

Please sign in to comment.