diff options
author | Sergei Shuvatov <[email protected]> | 2022-11-22 10:57:36 +0300 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2023-12-12 15:05:01 +0100 |
commit | 3f5f326b732e3dbd1c335b854e78f5927f2f48fa (patch) | |
tree | c450fdd2aff2c75609ab9073a34a65441589745c /test/handlers | |
parent | 0ce9696e5ee301d0e6791dd514d14c44e23c725a (diff) | |
download | cowboy-3f5f326b732e3dbd1c335b854e78f5927f2f48fa.tar.gz cowboy-3f5f326b732e3dbd1c335b854e78f5927f2f48fa.tar.bz2 cowboy-3f5f326b732e3dbd1c335b854e78f5927f2f48fa.zip |
Add test for send_timeout_close
LH: I reworked the test a little and added the same test
for HTTP/2 so that both HTTP/1.1 and HTTP/2 get the issue
fixed.
Diffstat (limited to 'test/handlers')
-rw-r--r-- | test/handlers/loop_handler_endless_h.erl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/handlers/loop_handler_endless_h.erl b/test/handlers/loop_handler_endless_h.erl new file mode 100644 index 0000000..f18361f --- /dev/null +++ b/test/handlers/loop_handler_endless_h.erl @@ -0,0 +1,24 @@ +%% This module implements a loop handler that streams endless data. + +-module(loop_handler_endless_h). + +-export([init/2]). +-export([info/3]). + +init(Req0, #{delay := Delay} = Opts) -> + case cowboy_req:header(<<"x-test-pid">>, Req0) of + BinPid when is_binary(BinPid) -> + Pid = list_to_pid(binary_to_list(BinPid)), + Pid ! {Pid, self(), init}, + ok; + _ -> + ok + end, + erlang:send_after(Delay, self(), timeout), + Req = cowboy_req:stream_reply(200, Req0), + {cowboy_loop, Req, Opts}. + +info(timeout, Req, State) -> + cowboy_req:stream_body(<<0:1000/unit:8>>, nofin, Req), + erlang:send_after(10, self(), timeout), + {ok, Req, State}. |