diff options
author | Loïc Hoguin <[email protected]> | 2018-09-12 16:16:29 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-09-12 16:16:29 +0200 |
commit | b56a5a1d60715ae115723c11c27ff7e032a3c4a5 (patch) | |
tree | 5997c621337049429f2197918319f9d6316565a1 /src | |
parent | 26bc4afad430c81f987597f409822452a8348657 (diff) | |
download | cowboy-b56a5a1d60715ae115723c11c27ff7e032a3c4a5.tar.gz cowboy-b56a5a1d60715ae115723c11c27ff7e032a3c4a5.tar.bz2 cowboy-b56a5a1d60715ae115723c11c27ff7e032a3c4a5.zip |
Do not send a 101 after a final response in switch_protocol
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_http.erl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index e1af0e9..71d33ce 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -1064,7 +1064,7 @@ commands(State0=#state{socket=Socket, transport=Transport}, StreamID, end; %% Protocol takeover. commands(State0=#state{ref=Ref, parent=Parent, socket=Socket, transport=Transport, - opts=Opts, children=Children}, StreamID, + out_state=OutState, opts=Opts, children=Children}, StreamID, [{switch_protocol, Headers, Protocol, InitialState}|_Tail]) -> %% @todo This should be the last stream running otherwise we need to wait before switching. %% @todo If there's streams opened after this one, fail instead of 101. @@ -1076,8 +1076,11 @@ commands(State0=#state{ref=Ref, parent=Parent, socket=Socket, transport=Transpor %% @todo Handle cases where the request came with a body. We need %% to process or skip the body before the upgrade can be completed. Transport:setopts(Socket, [{active, false}]), - %% Send a 101 response, then terminate the stream. - #state{streams=Streams} = info(State, StreamID, {inform, 101, Headers}), + %% Send a 101 response if necessary, then terminate the stream. + #state{streams=Streams} = case OutState of + wait -> info(State, StreamID, {inform, 101, Headers}); + _ -> State + end, #stream{state=StreamState} = lists:keyfind(StreamID, #stream.id, Streams), %% @todo We need to shutdown processes here first. stream_call_terminate(StreamID, switch_protocol, StreamState, State), |