mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Ensure stream terminate is called when switching protocols
This commit is contained in:
parent
debaecd49a
commit
4bebe39975
5 changed files with 42 additions and 14 deletions
|
@ -361,3 +361,26 @@ terminate_on_stop(Config) ->
|
|||
%% Confirm terminate/3 is called.
|
||||
receive {Self, Pid, terminate, _, _, _} -> ok after 1000 -> error(timeout) end,
|
||||
ok.
|
||||
|
||||
terminate_on_switch_protocol(Config) ->
|
||||
case config(protocol, Config) of
|
||||
http -> do_terminate_on_switch_protocol(Config);
|
||||
http2 -> doc("The switch_protocol command is not currently supported for HTTP/2.")
|
||||
end.
|
||||
|
||||
do_terminate_on_switch_protocol(Config) ->
|
||||
doc("Confirm terminate/3 is called after switch_protocol is returned."),
|
||||
Self = self(),
|
||||
ConnPid = gun_open(Config),
|
||||
Ref = gun:get(ConnPid, "/long_polling", [
|
||||
{<<"accept-encoding">>, <<"gzip">>},
|
||||
{<<"x-test-case">>, <<"terminate_on_switch_protocol">>},
|
||||
{<<"x-test-pid">>, pid_to_list(Self)}
|
||||
]),
|
||||
%% Confirm init/3 is called and receive the response.
|
||||
Pid = receive {Self, P, init, _, _, _} -> P after 1000 -> error(timeout) end,
|
||||
%% Confirm terminate/3 is called.
|
||||
receive {Self, Pid, terminate, _, _, _} -> ok after 1000 -> error(timeout) end,
|
||||
%% Confirm takeover/7 is called.
|
||||
receive {Self, Pid, takeover, _, _, _, _, _, _, _} -> ok after 1000 -> error(timeout) end,
|
||||
ok.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue