aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-02-07 11:32:15 +0100
committerLoïc Hoguin <[email protected]>2020-02-07 11:32:15 +0100
commit8fc3da2fc31a04281b0ba8dc0cdc1e1650067da5 (patch)
tree40756e591a9cec6226f30e7b5278fdf865d724be /test/handlers
parent47ecfd73181dc888f01479069cb7e076352da9ca (diff)
downloadcowboy-8fc3da2fc31a04281b0ba8dc0cdc1e1650067da5.tar.gz
cowboy-8fc3da2fc31a04281b0ba8dc0cdc1e1650067da5.tar.bz2
cowboy-8fc3da2fc31a04281b0ba8dc0cdc1e1650067da5.zip
Fix HTTP/1.1 bug when a flow command is returned after fin
This resulted in a badarith error due to the current flow being set to infinity when the body has been fully read. A test case has been added reproducing the issue.
Diffstat (limited to 'test/handlers')
-rw-r--r--test/handlers/stream_handler_h.erl4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/handlers/stream_handler_h.erl b/test/handlers/stream_handler_h.erl
index 3761e11..370d15a 100644
--- a/test/handlers/stream_handler_h.erl
+++ b/test/handlers/stream_handler_h.erl
@@ -34,6 +34,8 @@ init_commands(_, _, #state{test=crash_in_terminate}) ->
[{response, 200, #{<<"content-length">> => <<"12">>}, <<"Hello world!">>}, stop];
init_commands(_, _, #state{test=crash_in_early_error}) ->
error(crash);
+init_commands(_, _, #state{test=flow_after_body_fully_read}) ->
+ [];
init_commands(_, _, #state{test=set_options_ignore_unknown}) ->
[
{set_options, #{unknown_options => true}},
@@ -81,6 +83,8 @@ init_process(TrapExit, #state{pid=Pid}) ->
data(_, _, _, #state{test=crash_in_data}) ->
error(crash);
+data(_, fin, <<"Hello world!">>, State=#state{test=flow_after_body_fully_read}) ->
+ {[{flow, 12}, {response, 200, #{}, <<"{}">>}], State};
data(StreamID, IsFin, Data, State=#state{pid=Pid}) ->
Pid ! {Pid, self(), data, StreamID, IsFin, Data, State},
{[], State}.