0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Handle error_response command in cowboy_metrics_h

This commit is contained in:
Grigory Starinkin 2018-10-20 10:11:14 +01:00 committed by Loïc Hoguin
parent 473e3fb82b
commit 5ab5615ff0
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 145 additions and 0 deletions

View file

@ -222,6 +222,16 @@ fold([{response, Status, Headers, Body}|Tail],
resp_end=Resp,
resp_body_length=resp_body_length(Body)
});
fold([{error_response, Status, Headers, Body}|Tail],
State=#state{resp_status=RespStatus}) ->
%% The error_response command only results in a response
%% if no response was sent before.
case RespStatus of
undefined ->
fold([{response, Status, Headers, Body}|Tail], State);
_ ->
fold(Tail, State)
end;
fold([{headers, Status, Headers}|Tail],
State=#state{resp_headers_filter=RespHeadersFilter}) ->
RespStart = erlang:monotonic_time(),