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

Fix HTTP/1.1 stopping streams too early

It is possible in some cases to move on to the next request
without waiting, but that can be done as an optimization
later on if necessary.
This commit is contained in:
Loïc Hoguin 2017-10-20 13:16:04 +01:00
parent b9526a1745
commit c602871f86
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
3 changed files with 50 additions and 19 deletions

View file

@ -43,6 +43,8 @@ init_commands(_, _, State=#state{test=shutdown_timeout_on_stream_stop}) ->
init_commands(_, _, State=#state{test=shutdown_timeout_on_socket_close}) ->
Spawn = init_process(true, State),
[{headers, 200, #{}}, {spawn, Spawn, 2000}];
init_commands(_, _, State=#state{test=terminate_on_stop}) ->
[{response, 204, #{}, <<>>}];
init_commands(_, _, _) ->
[{headers, 200, #{}}].
@ -72,7 +74,10 @@ info(_, crash, #state{test=crash_in_info}) ->
error(crash);
info(StreamID, Info, State=#state{pid=Pid}) ->
Pid ! {Pid, self(), info, StreamID, Info, State},
{[], State}.
case Info of
please_stop -> {[stop], State};
_ -> {[], State}
end.
terminate(StreamID, Reason, State=#state{pid=Pid, test=crash_in_terminate}) ->
Pid ! {Pid, self(), terminate, StreamID, Reason, State},