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

Make the default 204 response go through stream handlers

This commit is contained in:
Loïc Hoguin 2017-04-18 16:07:01 +02:00
parent 6e8b907ae2
commit 061cc227b1
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
2 changed files with 13 additions and 11 deletions

View file

@ -913,19 +913,19 @@ stream_reset(State, StreamID, StreamError={internal_error, _, _}) ->
% stream_terminate(State#state{out_state=done}, StreamID, StreamError).
stream_terminate(State, StreamID, StreamError).
stream_terminate(State=#state{socket=Socket, transport=Transport,
stream_terminate(State0=#state{socket=Socket, transport=Transport,
out_streamid=OutStreamID, out_state=OutState,
streams=Streams0, children=Children0}, StreamID, Reason) ->
{value, #stream{state=StreamState, version=Version}, Streams}
= lists:keytake(StreamID, #stream.id, Streams0),
_ = case OutState of
State = case OutState of
wait ->
%% @todo This should probably go through the stream handler info callback.
Transport:send(Socket, cow_http:response(204, 'HTTP/1.1', []));
info(State0, StreamID, {response, 204, #{}, <<>>});
chunked when Version =:= 'HTTP/1.1' ->
Transport:send(Socket, <<"0\r\n\r\n">>);
_ = Transport:send(Socket, <<"0\r\n\r\n">>),
State0;
_ -> %% done or Version =:= 'HTTP/1.0'
ok
State0
end,
stream_call_terminate(StreamID, Reason, StreamState),