aboutsummaryrefslogtreecommitdiffstats
path: root/test/stream_handler_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-20 13:16:04 +0100
committerLoïc Hoguin <[email protected]>2017-10-20 13:16:04 +0100
commitc602871f86c795da8463908d12f7bf966bfeec12 (patch)
tree24795ef05335e4a23df9c2695b8a4431ccea1ac1 /test/stream_handler_SUITE.erl
parentb9526a1745cad73624a1a01a89f6498797c18443 (diff)
downloadcowboy-c602871f86c795da8463908d12f7bf966bfeec12.tar.gz
cowboy-c602871f86c795da8463908d12f7bf966bfeec12.tar.bz2
cowboy-c602871f86c795da8463908d12f7bf966bfeec12.zip
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.
Diffstat (limited to 'test/stream_handler_SUITE.erl')
-rw-r--r--test/stream_handler_SUITE.erl20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/stream_handler_SUITE.erl b/test/stream_handler_SUITE.erl
index 632adff..594e025 100644
--- a/test/stream_handler_SUITE.erl
+++ b/test/stream_handler_SUITE.erl
@@ -341,3 +341,23 @@ terminate_on_socket_close(Config) ->
%% Confirm terminate/3 is called.
receive {Self, Pid, terminate, _, _, _} -> ok after 1000 -> error(timeout) end,
ok.
+
+terminate_on_stop(Config) ->
+ doc("Confirm terminate/3 is called after stop is returned."),
+ Self = self(),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, "/long_polling", [
+ {<<"accept-encoding">>, <<"gzip">>},
+ {<<"x-test-case">>, <<"terminate_on_stop">>},
+ {<<"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,
+ {response, fin, 204, _} = gun:await(ConnPid, Ref),
+ %% Confirm the stream is still alive even though we
+ %% received the response fully, and tell it to stop.
+ Pid ! {{Pid, 1}, please_stop},
+ receive {Self, Pid, info, _, please_stop, _} -> ok after 1000 -> error(timeout) end,
+ %% Confirm terminate/3 is called.
+ receive {Self, Pid, terminate, _, _, _} -> ok after 1000 -> error(timeout) end,
+ ok.