aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorBartek Walkowicz <[email protected]>2018-03-01 14:49:57 +0100
committerLoïc Hoguin <[email protected]>2018-03-14 17:15:06 +0100
commit21317093285190f854acaf223db2e08f79069757 (patch)
treee234a0e8e32b39f87bdfc2282b09611d71a55fc8 /test/http_SUITE.erl
parentf9092126fafe063513444ca2b3c2aec6af14ed7b (diff)
downloadcowboy-21317093285190f854acaf223db2e08f79069757.tar.gz
cowboy-21317093285190f854acaf223db2e08f79069757.tar.bz2
cowboy-21317093285190f854acaf223db2e08f79069757.zip
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.
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl50
1 files changed, 49 insertions, 1 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index d77b760..a971e45 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -35,13 +35,16 @@ all() ->
{group, http_compress},
{group, https_compress},
{group, parse_host},
+ {group, request_timeout_infinity},
+ {group, idle_timeout_infinity},
{group, set_env},
{group, router_compile}
].
groups() ->
Tests = ct_helper:all(?MODULE) -- [
- parse_host, set_env_dispatch, path_allow_colon
+ parse_host, set_env_dispatch, path_allow_colon,
+ request_timeout_infinity, idle_timeout_infinity
],
[
{http, [], Tests}, %% @todo parallel
@@ -51,6 +54,12 @@ groups() ->
{parse_host, [], [
parse_host
]},
+ {request_timeout_infinity, [], [
+ request_timeout_infinity
+ ]},
+ {idle_timeout_infinity, [], [
+ idle_timeout_infinity
+ ]},
{set_env, [], [
set_env_dispatch
]},
@@ -84,6 +93,22 @@ init_per_group(parse_host, Config) ->
}),
Port = ranch:get_port(parse_host),
[{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config];
+init_per_group(request_timeout_infinity, Config) ->
+ Ref = request_timeout_infinity,
+ {ok, Pid} = cowboy:start_clear(Ref, [{port, 0}], #{
+ env => #{dispatch => init_dispatch(Config)},
+ request_timeout => infinity
+ }),
+ Port = ranch:get_port(request_timeout_infinity),
+ [{pid, Pid}, {ref, Ref}, {type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config];
+init_per_group(idle_timeout_infinity, Config) ->
+ Ref = idle_timeout_infinity,
+ {ok, Pid} = cowboy:start_clear(Ref, [{port, 0}], #{
+ env => #{dispatch => init_dispatch(Config)},
+ idle_timeout => infinity
+ }),
+ Port = ranch:get_port(idle_timeout_infinity),
+ [{pid, Pid}, {ref, Ref}, {type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config];
init_per_group(set_env, Config) ->
{ok, _} = cowboy:start_clear(set_env, [{port, 0}], #{
env => #{dispatch => []}
@@ -746,3 +771,26 @@ te_identity(Config) ->
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
{ok, Body} = gun:await_body(ConnPid, Ref),
ok.
+
+request_timeout_infinity(Config) ->
+ Pid = config(pid, Config),
+ Ref = erlang:monitor(process, Pid),
+ _ = gun_open(Config),
+ receive
+ {'DOWN', Ref, process, Pid, Reason} ->
+ error(Reason)
+ after 1000 ->
+ ok
+ end.
+
+idle_timeout_infinity(Config) ->
+ Pid = config(pid, Config),
+ Ref = erlang:monitor(process, Pid),
+ ConnPid = gun_open(Config),
+ gun:post(ConnPid, "/echo/body", [], <<"TEST">>),
+ receive
+ {'DOWN', Ref, process, Pid, Reason} ->
+ error(Reason)
+ after 1000 ->
+ ok
+ end.