diff options
author | Loïc Hoguin <[email protected]> | 2013-08-24 11:20:14 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-08-24 20:21:05 +0200 |
commit | bfb6db1eabb945777627a7ced8ab7f1dbc29af67 (patch) | |
tree | 6b288eb0ee65580e108fc440eaaf639ec37025a7 /src/cowboy_protocol.erl | |
parent | ac6c460169436a0f022983f3a614ac7ca3e313cd (diff) | |
download | cowboy-bfb6db1eabb945777627a7ced8ab7f1dbc29af67.tar.gz cowboy-bfb6db1eabb945777627a7ced8ab7f1dbc29af67.tar.bz2 cowboy-bfb6db1eabb945777627a7ced8ab7f1dbc29af67.zip |
Simpler code for sending errors following crashes
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r-- | src/cowboy_protocol.erl | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl index b42f524..40be2c0 100644 --- a/src/cowboy_protocol.erl +++ b/src/cowboy_protocol.erl @@ -573,29 +573,16 @@ next_request(Req, State=#state{req_keepalive=Keepalive, timeout=Timeout}, end end. -%% Only send an error reply if there is no resp_sent message. --spec error_terminate(cowboy:http_status(), cowboy_req:req(), #state{}) -> ok. -error_terminate(Code, Req, State) -> - receive - {cowboy_req, resp_sent} -> ok - after 0 -> - _ = cowboy_req:reply(Code, Req), - ok - end, - terminate(State). - -%% Only send an error reply if there is no resp_sent message. -spec error_terminate(cowboy:http_status(), #state{}) -> ok. -error_terminate(Code, State=#state{socket=Socket, transport=Transport, +error_terminate(Status, State=#state{socket=Socket, transport=Transport, compress=Compress, onresponse=OnResponse}) -> - receive - {cowboy_req, resp_sent} -> ok - after 0 -> - _ = cowboy_req:reply(Code, cowboy_req:new(Socket, Transport, - undefined, <<"GET">>, <<>>, <<>>, 'HTTP/1.1', [], <<>>, - undefined, <<>>, false, Compress, OnResponse)), - ok - end, + error_terminate(Status, cowboy_req:new(Socket, Transport, + undefined, <<"GET">>, <<>>, <<>>, 'HTTP/1.1', [], <<>>, + undefined, <<>>, false, Compress, OnResponse), State). + +-spec error_terminate(cowboy:http_status(), cowboy_req:req(), #state{}) -> ok. +error_terminate(Status, Req, State) -> + cowboy_req:maybe_reply(Status, Req), terminate(State). -spec terminate(#state{}) -> ok. |