aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/set_options_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-18 13:21:36 +0100
committerLoïc Hoguin <[email protected]>2018-11-18 13:25:12 +0100
commit8d6d78575f64055be2d0992d8ccf802d9efa1faa (patch)
treeee95f8c365487a23afb8c10c225c1a2128a945fc /test/handlers/set_options_h.erl
parent417032a445926ea79c42e82be25b384f2d17d8ac (diff)
downloadcowboy-8d6d78575f64055be2d0992d8ccf802d9efa1faa.tar.gz
cowboy-8d6d78575f64055be2d0992d8ccf802d9efa1faa.tar.bz2
cowboy-8d6d78575f64055be2d0992d8ccf802d9efa1faa.zip
Add the chunked option for HTTP/1.1
It allows disabling the chunked transfer-encoding. It can also be disabled on a per-request basis, although it will be ignored for responses that are not streamed.
Diffstat (limited to 'test/handlers/set_options_h.erl')
-rw-r--r--test/handlers/set_options_h.erl13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/handlers/set_options_h.erl b/test/handlers/set_options_h.erl
index a26bb98..1cefe92 100644
--- a/test/handlers/set_options_h.erl
+++ b/test/handlers/set_options_h.erl
@@ -8,6 +8,19 @@
init(Req, State) ->
set_options(cowboy_req:binding(key, Req), Req, State).
+set_options(<<"chunked_false">>, Req0, State) ->
+ %% @todo This should be replaced by a cowboy_req:cast/cowboy_stream:cast.
+ #{pid := Pid, streamid := StreamID} = Req0,
+ Pid ! {{Pid, StreamID}, {set_options, #{chunked => false}}},
+ Req = cowboy_req:stream_reply(200, Req0),
+ cowboy_req:stream_body(<<0:8000000>>, fin, Req),
+ {ok, Req, State};
+set_options(<<"chunked_false_ignored">>, Req0, State) ->
+ %% @todo This should be replaced by a cowboy_req:cast/cowboy_stream:cast.
+ #{pid := Pid, streamid := StreamID} = Req0,
+ Pid ! {{Pid, StreamID}, {set_options, #{chunked => false}}},
+ Req = cowboy_req:reply(200, #{}, <<"Hello world!">>, Req0),
+ {ok, Req, State};
set_options(<<"idle_timeout_short">>, Req0, State) ->
%% @todo This should be replaced by a cowboy_req:cast/cowboy_stream:cast.
#{pid := Pid, streamid := StreamID} = Req0,