mirror of
https://github.com/valitydev/woody_erlang.git
synced 2024-11-06 02:15:19 +00:00
MG-63: read the body in case of error to free the connection; add con… (#46)
This commit is contained in:
parent
75c4b97608
commit
905d087c7b
@ -125,18 +125,21 @@ handle_result({ok, 200, Headers, Ref}, Context) ->
|
||||
end,
|
||||
_ = log_event(?EV_CLIENT_RECEIVE, Context, Meta#{status => ok, code => 200}),
|
||||
get_body(hackney:body(Ref), Context);
|
||||
handle_result({ok, Code, Headers, _Ref}, Context) ->
|
||||
handle_result({ok, Code, Headers, Ref}, Context) ->
|
||||
{Class, Details} = check_error_headers(Code, Headers, Context),
|
||||
_ = log_event(?EV_CLIENT_RECEIVE, Context, #{status=>error, code=>Code, reason=>Details}),
|
||||
%% Read the body anyway to free the connection
|
||||
_ = hackney:body(Ref),
|
||||
{error, {system, {external, Class, Details}}};
|
||||
handle_result({error, {closed, _}}, Context) ->
|
||||
Reason = <<"partial response">>,
|
||||
_ = log_event(?EV_CLIENT_RECEIVE, Context, #{status => error, reason => Reason}),
|
||||
{error, {system, {external, result_unknown, Reason}}};
|
||||
handle_result({error, Reason}, Context) when
|
||||
Reason =:= timeout ;
|
||||
Reason =:= econnaborted ;
|
||||
Reason =:= enetreset ;
|
||||
Reason =:= timeout ;
|
||||
Reason =:= connect_timeout ;
|
||||
Reason =:= econnaborted ;
|
||||
Reason =:= enetreset ;
|
||||
Reason =:= econnreset
|
||||
->
|
||||
BinReason = woody_util:to_binary(Reason),
|
||||
|
Loading…
Reference in New Issue
Block a user