aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/compress_SUITE.erl21
-rw-r--r--test/http2_SUITE.erl43
-rw-r--r--test/http_SUITE.erl37
-rw-r--r--test/misc_SUITE.erl9
-rw-r--r--test/rfc7230_SUITE.erl5
-rw-r--r--test/rfc7540_SUITE.erl45
6 files changed, 75 insertions, 85 deletions
diff --git a/test/compress_SUITE.erl b/test/compress_SUITE.erl
index 1b82cc6..e42ff4f 100644
--- a/test/compress_SUITE.erl
+++ b/test/compress_SUITE.erl
@@ -18,7 +18,6 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
%% ct.
@@ -149,13 +148,12 @@ gzip_stream_reply_content_encoding(Config) ->
opts_compress_buffering_false(Config0) ->
doc("Confirm that the compress_buffering option can be set to false, "
"which is the default."),
- Name = name(),
Fun = case config(ref, Config0) of
https_compress -> init_https;
h2_compress -> init_http2;
_ -> init_http
end,
- Config = cowboy_test:Fun(Name, #{
+ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => false
@@ -175,19 +173,18 @@ opts_compress_buffering_false(Config0) ->
<<"data: World!\r\n\r\n">> = iolist_to_binary(zlib:inflate(Z, Data2)),
gun:close(ConnPid)
after
- cowboy:stop_listener(Name)
+ cowboy:stop_listener(?FUNCTION_NAME)
end.
opts_compress_buffering_true(Config0) ->
doc("Confirm that the compress_buffering option can be set to true, "
"and that the data received is buffered."),
- Name = name(),
Fun = case config(ref, Config0) of
https_compress -> init_https;
h2_compress -> init_http2;
_ -> init_http
end,
- Config = cowboy_test:Fun(Name, #{
+ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => true
@@ -205,19 +202,18 @@ opts_compress_buffering_true(Config0) ->
<<>> = iolist_to_binary(zlib:inflate(Z, Data1)),
gun:close(ConnPid)
after
- cowboy:stop_listener(Name)
+ cowboy:stop_listener(?FUNCTION_NAME)
end.
set_options_compress_buffering_false(Config0) ->
doc("Confirm that the compress_buffering option can be dynamically "
"set to false by a handler and that the data received is not buffered."),
- Name = name(),
Fun = case config(ref, Config0) of
https_compress -> init_https;
h2_compress -> init_http2;
_ -> init_http
end,
- Config = cowboy_test:Fun(Name, #{
+ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => true
@@ -237,19 +233,18 @@ set_options_compress_buffering_false(Config0) ->
<<"data: World!\r\n\r\n">> = iolist_to_binary(zlib:inflate(Z, Data2)),
gun:close(ConnPid)
after
- cowboy:stop_listener(Name)
+ cowboy:stop_listener(?FUNCTION_NAME)
end.
set_options_compress_buffering_true(Config0) ->
doc("Confirm that the compress_buffering option can be dynamically "
"set to true by a handler and that the data received is buffered."),
- Name = name(),
Fun = case config(ref, Config0) of
https_compress -> init_https;
h2_compress -> init_http2;
_ -> init_http
end,
- Config = cowboy_test:Fun(Name, #{
+ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => false
@@ -267,7 +262,7 @@ set_options_compress_buffering_true(Config0) ->
<<>> = iolist_to_binary(zlib:inflate(Z, Data1)),
gun:close(ConnPid)
after
- cowboy:stop_listener(Name)
+ cowboy:stop_listener(?FUNCTION_NAME)
end.
set_options_compress_threshold_0(Config) ->
diff --git a/test/http2_SUITE.erl b/test/http2_SUITE.erl
index 1fd33f9..ffed530 100644
--- a/test/http2_SUITE.erl
+++ b/test/http2_SUITE.erl
@@ -19,7 +19,6 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
-import(ct_helper, [get_remote_pid_tcp/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
all() -> [{group, clear}].
@@ -57,8 +56,8 @@ idle_timeout(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 1000
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]),
timer:sleep(1000),
%% Receive a GOAWAY frame back with NO_ERROR.
@@ -71,8 +70,8 @@ idle_timeout_infinity(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => infinity
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]),
timer:sleep(1000),
%% Don't receive a GOAWAY frame.
@@ -85,8 +84,8 @@ idle_timeout_reset_on_data(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 1000
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]),
%% We wait a little, send a PING, receive a PING ack.
{error, timeout} = gen_tcp:recv(Socket, 17, 500),
@@ -111,8 +110,8 @@ inactivity_timeout(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
inactivity_timeout => 1000
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]),
receive after 1000 -> ok end,
%% Receive a GOAWAY frame back with an INTERNAL_ERROR.
@@ -127,8 +126,8 @@ initial_connection_window_size(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
initial_connection_window_size => ConfiguredSize
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}]),
%% Send a valid preface.
ok = gen_tcp:send(Socket, ["PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", cow_http2:settings(#{})]),
@@ -148,8 +147,8 @@ max_frame_size_sent(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
max_frame_size_sent => MaxFrameSize
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake(#{max_frame_size => MaxFrameSize + 10000}, [{port, Port}|Config]),
%% Send a request with a 30000 bytes body.
{HeadersBlock, _} = cow_hpack:encode([
@@ -178,7 +177,7 @@ max_frame_size_sent(Config) ->
{ok, <<20000:24, 0:8, _:40, _:20000/unit:8>>} = gen_tcp:recv(Socket, 20009, 6000),
{ok, <<10000:24, 0:8, _:40, _:10000/unit:8>>} = gen_tcp:recv(Socket, 10009, 6000),
%% Stop the listener.
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
preface_timeout_infinity(Config) ->
doc("Ensure infinity for preface_timeout is accepted."),
@@ -186,8 +185,8 @@ preface_timeout_infinity(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
preface_timeout => infinity
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]),
Pid = get_remote_pid_tcp(Socket),
Ref = erlang:monitor(process, Pid),
@@ -195,7 +194,7 @@ preface_timeout_infinity(Config) ->
{'DOWN', Ref, process, Pid, Reason} ->
error(Reason)
after 1000 ->
- cowboy:stop_listener(name())
+ cowboy:stop_listener(?FUNCTION_NAME)
end.
resp_iolist_body(Config) ->
@@ -205,8 +204,8 @@ resp_iolist_body(Config) ->
ProtoOpts = #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))}
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http2}, {port, Port}|Config]),
Ref = gun:get(ConnPid, "/resp_iolist_body"),
{response, nofin, 200, RespHeaders} = gun:await(ConnPid, Ref),
@@ -222,8 +221,8 @@ settings_timeout_infinity(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
settings_timeout => infinity
},
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
- Port = ranch:get_port(name()),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]),
Pid = get_remote_pid_tcp(Socket),
Ref = erlang:monitor(process, Pid),
@@ -231,5 +230,5 @@ settings_timeout_infinity(Config) ->
{'DOWN', Ref, process, Pid, Reason} ->
error(Reason)
after 1000 ->
- cowboy:stop_listener(name())
+ cowboy:stop_listener(?FUNCTION_NAME)
end.
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 1d6c3fc..c16215e 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -19,7 +19,6 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
-import(ct_helper, [get_remote_pid_tcp/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [raw_open/1]).
-import(cowboy_test, [raw_send/2]).
@@ -43,11 +42,11 @@ init_routes(_) -> [
chunked_false(Config) ->
doc("Confirm the option chunked => false disables chunked "
"transfer-encoding for HTTP/1.1 connections."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => false
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
Request = "GET /resp/stream_reply2/200 HTTP/1.1\r\nhost: localhost\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request),
@@ -69,11 +68,11 @@ chunked_false(Config) ->
http10_keepalive_false(Config) ->
doc("Confirm the option http10_keepalive => false disables keep-alive "
"completely for HTTP/1.0 connections."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
http10_keepalive => false
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
Keepalive = "GET / HTTP/1.0\r\nhost: localhost\r\nConnection: keep-alive\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Keepalive),
@@ -93,12 +92,12 @@ http10_keepalive_false(Config) ->
idle_timeout_infinity(Config) ->
doc("Ensure the idle_timeout option accepts the infinity value."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
request_timeout => 500,
idle_timeout => infinity
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/echo/read_body",
[{<<"content-type">>, <<"text/plain">>}]),
@@ -114,11 +113,11 @@ idle_timeout_infinity(Config) ->
request_timeout_infinity(Config) ->
doc("Ensure the request_timeout option accepts the infinity value."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => infinity
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
#{socket := Socket} = gun:info(ConnPid),
Pid = get_remote_pid_tcp(Socket),
@@ -134,11 +133,11 @@ set_options_chunked_false(Config) ->
doc("Confirm the option chunked can be dynamically set to disable "
"chunked transfer-encoding. This results in the closing of the "
"connection after the current request."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => true
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
Request = "GET /set_options/chunked_false HTTP/1.1\r\nhost: localhost\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request),
@@ -159,11 +158,11 @@ set_options_chunked_false_ignored(Config) ->
doc("Confirm the option chunked can be dynamically set to disable "
"chunked transfer-encoding, and that it is ignored if the "
"response is not streamed."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => true
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
%% We do a first request setting the option but not
%% using chunked transfer-encoding in the response.
@@ -181,11 +180,11 @@ set_options_idle_timeout(Config) ->
doc("Confirm that the idle_timeout option can be dynamically "
"set to change how long Cowboy will wait before it closes the connection."),
%% We start with a long timeout and then cut it short.
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 60000
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/set_options/idle_timeout_short",
[{<<"content-type">>, <<"text/plain">>}]),
@@ -202,11 +201,11 @@ set_options_idle_timeout(Config) ->
set_options_idle_timeout_only_applies_to_current_request(Config) ->
doc("Confirm that changes to the idle_timeout option only apply to the current stream."),
%% We start with a long timeout and then cut it short.
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 500
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
StreamRef = gun:post(ConnPid, "/set_options/idle_timeout_long",
[{<<"content-type">>, <<"text/plain">>}]),
@@ -239,8 +238,8 @@ switch_protocol_flush(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
stream_handlers => [switch_protocol_flush_h]
},
- {ok, _} = cowboy:start_clear(switch_protocol_flush, [{port, 0}], ProtoOpts),
- Port = ranch:get_port(switch_protocol_flush),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
Self = self(),
ConnPid = gun_open([{port, Port}, {type, tcp}, {protocol, http}|Config]),
_ = gun:get(ConnPid, "/", [
diff --git a/test/misc_SUITE.erl b/test/misc_SUITE.erl
index 6f44774..4ad2325 100644
--- a/test/misc_SUITE.erl
+++ b/test/misc_SUITE.erl
@@ -18,7 +18,6 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
all() ->
@@ -80,13 +79,13 @@ router_invalid_path(Config) ->
set_env(Config0) ->
doc("Live replace a middleware environment value."),
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => []}
}, Config0),
ConnPid1 = gun_open(Config),
Ref1 = gun:get(ConnPid1, "/"),
{response, _, 400, _} = gun:await(ConnPid1, Ref1),
- cowboy:set_env(name(), dispatch, init_dispatch(Config)),
+ cowboy:set_env(?FUNCTION_NAME, dispatch, init_dispatch(Config)),
%% Only new connections get the updated environment.
ConnPid2 = gun_open(Config),
Ref2 = gun:get(ConnPid2, "/"),
@@ -95,11 +94,11 @@ set_env(Config0) ->
set_env_missing(Config0) ->
doc("Live replace a middleware environment value when env was not provided."),
- Config = cowboy_test:init_http(name(), #{}, Config0),
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{}, Config0),
ConnPid1 = gun_open(Config),
Ref1 = gun:get(ConnPid1, "/"),
{response, _, 500, _} = gun:await(ConnPid1, Ref1),
- cowboy:set_env(name(), dispatch, []),
+ cowboy:set_env(?FUNCTION_NAME, dispatch, []),
%% Only new connections get the updated environment.
ConnPid2 = gun_open(Config),
Ref2 = gun:get(ConnPid2, "/"),
diff --git a/test/rfc7230_SUITE.erl b/test/rfc7230_SUITE.erl
index 6887d27..d42a454 100644
--- a/test/rfc7230_SUITE.erl
+++ b/test/rfc7230_SUITE.erl
@@ -17,7 +17,6 @@
-compile(nowarn_export_all).
-import(ct_helper, [doc/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [gun_down/1]).
-import(cowboy_test, [raw_open/1]).
@@ -1591,7 +1590,7 @@ reject_absolute_form_different_host(Config) ->
empty_host(Config0) ->
doc("The host header is empty when the authority component is undefined. (RFC7230 5.4)"),
Routes = [{'_', [{"/echo/:key[/:arg]", echo_h, []}]}],
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(Routes)}
}, Config0),
#{code := 200, body := <<>>} = do_raw(Config, [
@@ -1602,7 +1601,7 @@ empty_host(Config0) ->
"GET /echo/host HTTP/1.1\r\n"
"Host: \r\n"
"\r\n"]),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
%% The effective request URI can be rebuilt by concatenating scheme,
%% "://", authority, path and query components. (RFC7230 5.5)
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 4708f06..2f20a59 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -18,7 +18,6 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [raw_open/1]).
-import(cowboy_test, [raw_send/2]).
@@ -1324,7 +1323,7 @@ max_frame_size_allow_exactly_custom(Config0) ->
doc("An endpoint that sets SETTINGS_MAX_FRAME_SIZE must allow frames "
"of up to that size. (RFC7540 4.2, RFC7540 6.5.2)"),
%% Create a new listener that sets the maximum frame size to 30000.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_frame_size_received => 30000
}, Config0),
@@ -1348,13 +1347,13 @@ max_frame_size_allow_exactly_custom(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of a 25000 bytes frame.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
max_frame_size_reject_larger_than_custom(Config0) ->
doc("An endpoint that sets SETTINGS_MAX_FRAME_SIZE must reject frames "
"of up to that size with a FRAME_SIZE_ERROR connection error. (RFC7540 4.2, RFC7540 6.5.2)"),
%% Create a new listener that sets the maximum frame size to 30000.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_frame_size_received => 30000
}, Config0),
@@ -1375,7 +1374,7 @@ max_frame_size_reject_larger_than_custom(Config0) ->
]),
%% Receive a FRAME_SIZE_ERROR connection error.
{ok, << _:24, 7:8, _:72, 6:32 >>} = gen_tcp:recv(Socket, 17, 6000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
%% I am using FRAME_SIZE_ERROR here because the information in the
%% frame header tells us this frame is at least 1 byte long, while
@@ -2552,7 +2551,7 @@ settings_header_table_size_server(Config0) ->
"used by the server to decode header blocks. (RFC7540 6.5.2)"),
HeaderTableSize = 128,
%% Create a new listener that allows larger header table sizes.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_decode_table_size => HeaderTableSize
}, Config0),
@@ -2589,13 +2588,13 @@ settings_header_table_size_server(Config0) ->
{_, <<"200">>} = lists:keyfind(<<":status">>, 1, RespHeaders),
%% The decoding succeeded on the server, confirming that
%% the table size was updated to HeaderTableSize.
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
settings_max_concurrent_streams(Config0) ->
doc("The SETTINGS_MAX_CONCURRENT_STREAMS setting can be used to "
"restrict the number of concurrent streams. (RFC7540 5.1.2, RFC7540 6.5.2)"),
%% Create a new listener that allows only a single concurrent stream.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_concurrent_streams => 1
}, Config0),
@@ -2615,13 +2614,13 @@ settings_max_concurrent_streams(Config0) ->
]),
%% Receive a REFUSED_STREAM stream error.
{ok, << _:24, 3:8, _:8, 3:32, 7:32 >>} = gen_tcp:recv(Socket, 13, 6000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
settings_max_concurrent_streams_0(Config0) ->
doc("The SETTINGS_MAX_CONCURRENT_STREAMS setting can be set to "
"0 to refuse all incoming streams. (RFC7540 5.1.2, RFC7540 6.5.2)"),
%% Create a new listener that allows only a single concurrent stream.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_concurrent_streams => 0
}, Config0),
@@ -2636,7 +2635,7 @@ settings_max_concurrent_streams_0(Config0) ->
ok = gen_tcp:send(Socket, cow_http2:headers(1, fin, HeadersBlock)),
%% Receive a REFUSED_STREAM stream error.
{ok, << _:24, 3:8, _:8, 1:32, 7:32 >>} = gen_tcp:recv(Socket, 13, 6000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
%% @todo The client can limit the number of concurrent streams too. (RFC7540 5.1.2)
%
@@ -2659,7 +2658,7 @@ settings_initial_window_size(Config0) ->
doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to "
"change the initial window size of streams. (RFC7540 6.5.2)"),
%% Create a new listener that sets initial window sizes to 100000.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_connection_window_size => 100000,
initial_stream_window_size => 100000
@@ -2701,14 +2700,14 @@ settings_initial_window_size(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of more than 65535 bytes of data.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
settings_initial_window_size_after_ack(Config0) ->
doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to "
"change the initial window size of streams. It is applied "
"to all existing streams upon receipt of the SETTINGS ack. (RFC7540 6.5.2)"),
%% Create a new listener that sets the initial stream window sizes to 0.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_stream_window_size => 0
}, Config0),
@@ -2741,14 +2740,14 @@ settings_initial_window_size_after_ack(Config0) ->
]),
%% Receive a FLOW_CONTROL_ERROR stream error.
{ok, << _:24, 3:8, _:8, 1:32, 3:32 >>} = gen_tcp:recv(Socket, 13, 6000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
settings_initial_window_size_before_ack(Config0) ->
doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to "
"change the initial window size of streams. It is only "
"applied upon receipt of the SETTINGS ack. (RFC7540 6.5.2)"),
%% Create a new listener that sets the initial stream window sizes to 0.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_stream_window_size => 0
}, Config0),
@@ -2786,13 +2785,13 @@ settings_initial_window_size_before_ack(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of more than 0 bytes of data.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
settings_max_frame_size(Config0) ->
doc("The SETTINGS_MAX_FRAME_SIZE setting can be used to "
"change the maximum frame size allowed. (RFC7540 6.5.2)"),
%% Create a new listener that sets the maximum frame size to 30000.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_frame_size_received => 30000
}, Config0),
@@ -2816,7 +2815,7 @@ settings_max_frame_size(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of a 25000 bytes frame.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
settings_max_frame_size_reject_too_small(Config) ->
doc("A SETTINGS_MAX_FRAME_SIZE smaller than 16384 must be rejected "
@@ -3012,7 +3011,7 @@ data_reject_overflow(Config0) ->
"to overflow must be rejected with a FLOW_CONTROL_ERROR "
"connection error. (RFC7540 6.9.1)"),
%% Create a new listener that allows only a single concurrent stream.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_stream_window_size => 100000
}, Config0),
@@ -3037,14 +3036,14 @@ data_reject_overflow(Config0) ->
]),
%% Receive a FLOW_CONTROL_ERROR connection error.
{ok, << _:24, 7:8, _:72, 3:32 >>} = gen_tcp:recv(Socket, 17, 6000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
data_reject_overflow_stream(Config0) ->
doc("DATA frames that cause the stream flow control window "
"to overflow must be rejected with a FLOW_CONTROL_ERROR "
"stream error. (RFC7540 6.9.1)"),
%% Create a new listener that allows only a single concurrent stream.
- Config = cowboy_test:init_http(name(), #{
+ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_connection_window_size => 100000
}, Config0),
@@ -3082,7 +3081,7 @@ data_reject_overflow_stream(Config0) ->
]),
%% Receive a FLOW_CONTROL_ERROR stream error.
{ok, << _:24, 3:8, _:8, 1:32, 3:32 >>} = gen_tcp:recv(Socket, 13, 6000),
- cowboy:stop_listener(name()).
+ cowboy:stop_listener(?FUNCTION_NAME).
%% (RFC7540 6.9.1)
% Frames with zero length with the END_STREAM flag set (that