From 2e8fcb9a9ef9ef9beff25ed4d48cf0d90609a69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 7 Oct 2019 13:25:49 +0200 Subject: Add cowboy_req:cast/2 Better than sending messages manually. --- test/handlers/compress_h.erl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'test/handlers/compress_h.erl') diff --git a/test/handlers/compress_h.erl b/test/handlers/compress_h.erl index 76c2db1..27edbd3 100644 --- a/test/handlers/compress_h.erl +++ b/test/handlers/compress_h.erl @@ -24,9 +24,7 @@ init(Req0, State=reply) -> Size = filelib:file_size(AppFile), cowboy_req:reply(200, #{}, {sendfile, 0, Size, AppFile}, Req0); <<"set_options_threshold0">> -> - %% @todo This should be replaced by a cowboy_req:cast/cowboy_stream:cast. - #{pid := Pid, streamid := StreamID} = Req0, - Pid ! {{Pid, StreamID}, {set_options, #{compress_threshold => 0}}}, + cowboy_req:cast({set_options, #{compress_threshold => 0}}, Req0), cowboy_req:reply(200, #{}, lists:duplicate(100, $a), Req0) end, {ok, Req, State}; @@ -62,14 +60,10 @@ init(Req0, State=stream_reply) -> <<"delayed">> -> stream_delayed(Req0); <<"set_options_buffering_false">> -> - %% @todo This should be replaced by a cowboy_req:cast/cowboy_stream:cast. - #{pid := Pid, streamid := StreamID} = Req0, - Pid ! {{Pid, StreamID}, {set_options, #{compress_buffering => false}}}, + cowboy_req:cast({set_options, #{compress_buffering => false}}, Req0), stream_delayed(Req0); <<"set_options_buffering_true">> -> - %% @todo This should be replaced by a cowboy_req:cast/cowboy_stream:cast. - #{pid := Pid, streamid := StreamID} = Req0, - Pid ! {{Pid, StreamID}, {set_options, #{compress_buffering => true}}}, + cowboy_req:cast({set_options, #{compress_buffering => true}}, Req0), stream_delayed(Req0) end, {ok, Req, State}. -- cgit v1.2.3