aboutsummaryrefslogtreecommitdiffstats
path: root/test/stream_handler_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-22 14:53:04 +0100
committerLoïc Hoguin <[email protected]>2017-10-22 14:53:04 +0100
commit4bebe39975aab28962ac3850aa25a7d768c349bb (patch)
treea805886c2c37ed3c8827cb1572c194a8eba163cb /test/stream_handler_SUITE.erl
parentdebaecd49ae3efab4c319f3ec67677c82fe9e9a5 (diff)
downloadcowboy-4bebe39975aab28962ac3850aa25a7d768c349bb.tar.gz
cowboy-4bebe39975aab28962ac3850aa25a7d768c349bb.tar.bz2
cowboy-4bebe39975aab28962ac3850aa25a7d768c349bb.zip
Ensure stream terminate is called when switching protocols
Diffstat (limited to 'test/stream_handler_SUITE.erl')
-rw-r--r--test/stream_handler_SUITE.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/stream_handler_SUITE.erl b/test/stream_handler_SUITE.erl
index 594e025..33470eb 100644
--- a/test/stream_handler_SUITE.erl
+++ b/test/stream_handler_SUITE.erl
@@ -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.