0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Add case for handling infinity for idle/request_timeout

Currently cowboy assumes that idle_timeout or request_timeout is
a number and always starts timers. Similar situation takes place
in case of preface_timeout for http2. This commit adds case for
handling infinity as a timeout, allowing to not start mentioned
timers.
This commit is contained in:
Bartek Walkowicz 2018-03-01 14:49:57 +01:00 committed by Loïc Hoguin
parent f9092126fa
commit 2131709328
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
4 changed files with 79 additions and 7 deletions

View file

@ -59,6 +59,23 @@ inactivity_timeout(Config) ->
{ok, << _:24, 7:8, _:72, 2:32 >>} = gen_tcp:recv(Socket, 17, 1000),
ok.
preface_timeout_infinity(Config) ->
doc("Ensure infinity for preface_timeout is accepted"),
ProtoOpts = #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
preface_timeout => infinity
},
{ok, Pid} = cowboy:start_clear(preface_timeout_infinity, [{port, 0}], ProtoOpts),
Ref = erlang:monitor(process, Pid),
Port = ranch:get_port(preface_timeout_infinity),
{ok, _} = do_handshake([{port, Port}|Config]),
receive
{'DOWN', Ref, process, Pid, Reason} ->
error(Reason)
after 1000 ->
cowboy:stop_listener(preface_timeout_infinity)
end.
resp_iolist_body(Config) ->
doc("Regression test when response bodies are iolists that "
"include improper lists, empty lists and empty binaries. "