aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-03-20 19:29:32 +0100
committerLoïc Hoguin <[email protected]>2011-03-20 19:29:32 +0100
commita1e56a2fba417b3b8d145e04b3de4ab8dc87af40 (patch)
tree12646c7f92cf1db12354412084d4b891c2329254 /src/cowboy_http_protocol.erl
parent71b31cee92f5e0c92f57e94c4916e9e19bbafb3f (diff)
downloadcowboy-a1e56a2fba417b3b8d145e04b3de4ab8dc87af40.tar.gz
cowboy-a1e56a2fba417b3b8d145e04b3de4ab8dc87af40.tar.bz2
cowboy-a1e56a2fba417b3b8d145e04b3de4ab8dc87af40.zip
Move the error response code into a separate function.
Diffstat (limited to 'src/cowboy_http_protocol.erl')
-rw-r--r--src/cowboy_http_protocol.erl12
1 files changed, 9 insertions, 3 deletions
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),