From a1e56a2fba417b3b8d145e04b3de4ab8dc87af40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 20 Mar 2011 19:29:32 +0100 Subject: Move the error response code into a separate function. --- src/cowboy_http_protocol.erl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl index 4b3c40b..e225b5c 100644 --- a/src/cowboy_http_protocol.erl +++ b/src/cowboy_http_protocol.erl @@ -165,11 +165,17 @@ handler_terminate(HandlerState, Req, State=#state{handler={Handler, _Opts}}) -> end. -spec error_terminate(Code::http_status(), State::#state{}) -> ok. -error_terminate(Code, State=#state{socket=Socket, transport=Transport}) -> - cowboy_http_req:reply(Code, [], [], #http_req{socket=Socket, - transport=Transport, connection=close}), +error_terminate(Code, State) -> + error_response(Code, State#state{connection=close}), terminate(State). +-spec error_response(Code::http_status(), State::#state{}) -> ok. +error_response(Code, #state{socket=Socket, + transport=Transport, connection=Connection}) -> + cowboy_http_req:reply(Code, [], [], #http_req{ + socket=Socket, transport=Transport, + connection=Connection, resp_state=waiting}). + -spec terminate(State::#state{}) -> ok. terminate(#state{socket=Socket, transport=Transport}) -> Transport:close(Socket), -- cgit v1.2.3