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

Move the error response code into a separate function.

This commit is contained in:
Loïc Hoguin 2011-03-20 19:29:32 +01:00
parent 71b31cee92
commit a1e56a2fba

View file

@ -165,11 +165,17 @@ handler_terminate(HandlerState, Req, State=#state{handler={Handler, _Opts}}) ->
end. end.
-spec error_terminate(Code::http_status(), State::#state{}) -> ok. -spec error_terminate(Code::http_status(), State::#state{}) -> ok.
error_terminate(Code, State=#state{socket=Socket, transport=Transport}) -> error_terminate(Code, State) ->
cowboy_http_req:reply(Code, [], [], #http_req{socket=Socket, error_response(Code, State#state{connection=close}),
transport=Transport, connection=close}),
terminate(State). 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. -spec terminate(State::#state{}) -> ok.
terminate(#state{socket=Socket, transport=Transport}) -> terminate(#state{socket=Socket, transport=Transport}) ->
Transport:close(Socket), Transport:close(Socket),