aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-16 13:09:01 +0100
committerLoïc Hoguin <[email protected]>2018-11-16 13:09:01 +0100
commit75045637fc6026054900f2dbea75805ad7c8e682 (patch)
treea7d426e8a463de52127981758e6e6624c30b609c /src
parent1949357f0cbcc1e6c94add457c7cad90d35340c1 (diff)
downloadcowboy-75045637fc6026054900f2dbea75805ad7c8e682.tar.gz
cowboy-75045637fc6026054900f2dbea75805ad7c8e682.tar.bz2
cowboy-75045637fc6026054900f2dbea75805ad7c8e682.zip
Ensure unknown options are ignored in set_options command
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_compress_h.erl6
-rw-r--r--src/cowboy_http2.erl3
2 files changed, 7 insertions, 2 deletions
diff --git a/src/cowboy_compress_h.erl b/src/cowboy_compress_h.erl
index 95c49d3..f4ee7b9 100644
--- a/src/cowboy_compress_h.erl
+++ b/src/cowboy_compress_h.erl
@@ -141,7 +141,8 @@ fold([Trailers={trailers, _}|Tail], State0=#state{compress=gzip}, Acc) ->
{{data, fin, Data}, State} = gzip_data({data, fin, <<>>}, State0),
fold(Tail, State, [Trailers, {data, nofin, Data}|Acc]);
%% All the options from this handler can be updated for the current stream.
-fold([{set_options, Opts}|Tail], State=#state{
+%% The set_options command must be propagated as-is regardless.
+fold([SetOptions={set_options, Opts}|Tail], State=#state{
threshold=CompressThreshold0, deflate_flush=DeflateFlush0}, Acc) ->
CompressThreshold = maps:get(compress_threshold, Opts, CompressThreshold0),
DeflateFlush = case Opts of
@@ -150,7 +151,8 @@ fold([{set_options, Opts}|Tail], State=#state{
_ ->
DeflateFlush0
end,
- fold(Tail, State#state{threshold=CompressThreshold, deflate_flush=DeflateFlush}, Acc);
+ fold(Tail, State#state{threshold=CompressThreshold, deflate_flush=DeflateFlush},
+ [SetOptions|Acc]);
%% Otherwise, we have an unrelated command or compression is disabled.
fold([Command|Tail], State, Acc) ->
fold(Tail, State, [Command|Acc]).
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index 3397241..b83c021 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -576,6 +576,9 @@ commands(State=#state{socket=Socket, transport=Transport, http2_init=upgrade},
commands(State0, StreamID, [{switch_protocol, Headers, _Mod, _ModState}|Tail]) ->
State = info(State0, StreamID, {headers, 200, Headers}),
commands(State, StreamID, Tail);
+%% Set options dynamically.
+commands(State, StreamID, [{set_options, _Opts}|Tail]) ->
+ commands(State, StreamID, Tail);
commands(State, StreamID, [stop|_Tail]) ->
%% @todo Do we want to run the commands after a stop?
%% @todo Do we even allow commands after?