aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-12-12 11:37:48 +0100
committerLoïc Hoguin <[email protected]>2017-12-12 11:37:48 +0100
commiteafca21198b08dfa356cb9b1ec87f80375a2af23 (patch)
tree8ac377df5ac4591c5a71fbc875b8fffa8ef65b15 /src
parent01e13c0846a15a1f18ac586b68a6b9e6feb5c692 (diff)
downloadcowboy-eafca21198b08dfa356cb9b1ec87f80375a2af23.tar.gz
cowboy-eafca21198b08dfa356cb9b1ec87f80375a2af23.tar.bz2
cowboy-eafca21198b08dfa356cb9b1ec87f80375a2af23.zip
Fix HTTP/1.1 pipelining
Cases where a request body was involved could sometimes fail depending on timing. Also fix all of the old http_SUITE tests.
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_http.erl11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl
index 2301abb..9fc098d 100644
--- a/src/cowboy_http.erl
+++ b/src/cowboy_http.erl
@@ -1051,8 +1051,9 @@ stream_reset(State, StreamID, StreamError={internal_error, _, _}) ->
% stream_terminate(State#state{out_state=done}, StreamID, StreamError).
stream_terminate(State, StreamID, StreamError).
-stream_terminate(State0=#state{opts=Opts, in_state=InState, out_streamid=OutStreamID,
- out_state=OutState, streams=Streams0, children=Children0}, StreamID, Reason) ->
+stream_terminate(State0=#state{opts=Opts, in_streamid=InStreamID, in_state=InState,
+ out_streamid=OutStreamID, out_state=OutState, streams=Streams0,
+ children=Children0}, StreamID, Reason) ->
#stream{version=Version} = lists:keyfind(StreamID, #stream.id, Streams0),
State1 = #state{streams=Streams1} = case OutState of
wait when element(1, Reason) =:= internal_error ->
@@ -1084,9 +1085,11 @@ stream_terminate(State0=#state{opts=Opts, in_state=InState, out_streamid=OutStre
%% @todo Only do this if Current =:= StreamID.
MaxSkipBodyLength = maps:get(max_skip_body_length, Opts, 1000000),
case InState of
- #ps_body{length=undefined} ->
+ #ps_body{length=undefined}
+ when InStreamID =:= OutStreamID ->
terminate(State#state{streams=Streams, children=Children}, skip_body_unknown_length);
- #ps_body{length=Len, received=Received} when Received + MaxSkipBodyLength < Len ->
+ #ps_body{length=Len, received=Received}
+ when InStreamID =:= OutStreamID, Received + MaxSkipBodyLength < Len ->
terminate(State#state{streams=Streams, children=Children}, skip_body_too_large);
_ ->
%% Move on to the next stream.