aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
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 'src')
-rw-r--r--src/cowboy_http.erl3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl
index 9f0b865..13d07b7 100644
--- a/src/cowboy_http.erl
+++ b/src/cowboy_http.erl
@@ -970,6 +970,9 @@ commands(State=#state{out_streamid=Current, streams=Streams0}, StreamID, Command
Streams = lists:keyreplace(StreamID, #stream.id, Streams0,
Stream#stream{queue=Queue ++ Commands}),
State#state{streams=Streams};
+%% When we have finished reading the request body, do nothing.
+commands(State=#state{flow=infinity}, StreamID, [{flow, _}|Tail]) ->
+ commands(State, StreamID, Tail);
%% Read the request body.
commands(State0=#state{flow=Flow0}, StreamID, [{flow, Size}|Tail]) ->
%% We must read *at least* Size of data otherwise functions