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

Use ?FUNCTION_NAME instead of ct_helper:name()

Cowboy is 19+ so it's OK to use it.
This commit is contained in:
Loïc Hoguin 2018-11-19 09:05:34 +01:00
parent 6cc3b0ccca
commit bed328b6c9
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
6 changed files with 75 additions and 85 deletions

View file

@ -18,7 +18,6 @@
-import(ct_helper, [config/2]). -import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]). -import(ct_helper, [doc/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]). -import(cowboy_test, [gun_open/1]).
%% ct. %% ct.
@ -149,13 +148,12 @@ gzip_stream_reply_content_encoding(Config) ->
opts_compress_buffering_false(Config0) -> opts_compress_buffering_false(Config0) ->
doc("Confirm that the compress_buffering option can be set to false, " doc("Confirm that the compress_buffering option can be set to false, "
"which is the default."), "which is the default."),
Name = name(),
Fun = case config(ref, Config0) of Fun = case config(ref, Config0) of
https_compress -> init_https; https_compress -> init_https;
h2_compress -> init_http2; h2_compress -> init_http2;
_ -> init_http _ -> init_http
end, end,
Config = cowboy_test:Fun(Name, #{ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)}, env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h], stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => false 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)), <<"data: World!\r\n\r\n">> = iolist_to_binary(zlib:inflate(Z, Data2)),
gun:close(ConnPid) gun:close(ConnPid)
after after
cowboy:stop_listener(Name) cowboy:stop_listener(?FUNCTION_NAME)
end. end.
opts_compress_buffering_true(Config0) -> opts_compress_buffering_true(Config0) ->
doc("Confirm that the compress_buffering option can be set to true, " doc("Confirm that the compress_buffering option can be set to true, "
"and that the data received is buffered."), "and that the data received is buffered."),
Name = name(),
Fun = case config(ref, Config0) of Fun = case config(ref, Config0) of
https_compress -> init_https; https_compress -> init_https;
h2_compress -> init_http2; h2_compress -> init_http2;
_ -> init_http _ -> init_http
end, end,
Config = cowboy_test:Fun(Name, #{ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)}, env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h], stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => true compress_buffering => true
@ -205,19 +202,18 @@ opts_compress_buffering_true(Config0) ->
<<>> = iolist_to_binary(zlib:inflate(Z, Data1)), <<>> = iolist_to_binary(zlib:inflate(Z, Data1)),
gun:close(ConnPid) gun:close(ConnPid)
after after
cowboy:stop_listener(Name) cowboy:stop_listener(?FUNCTION_NAME)
end. end.
set_options_compress_buffering_false(Config0) -> set_options_compress_buffering_false(Config0) ->
doc("Confirm that the compress_buffering option can be dynamically " doc("Confirm that the compress_buffering option can be dynamically "
"set to false by a handler and that the data received is not buffered."), "set to false by a handler and that the data received is not buffered."),
Name = name(),
Fun = case config(ref, Config0) of Fun = case config(ref, Config0) of
https_compress -> init_https; https_compress -> init_https;
h2_compress -> init_http2; h2_compress -> init_http2;
_ -> init_http _ -> init_http
end, end,
Config = cowboy_test:Fun(Name, #{ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)}, env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h], stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => true 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)), <<"data: World!\r\n\r\n">> = iolist_to_binary(zlib:inflate(Z, Data2)),
gun:close(ConnPid) gun:close(ConnPid)
after after
cowboy:stop_listener(Name) cowboy:stop_listener(?FUNCTION_NAME)
end. end.
set_options_compress_buffering_true(Config0) -> set_options_compress_buffering_true(Config0) ->
doc("Confirm that the compress_buffering option can be dynamically " doc("Confirm that the compress_buffering option can be dynamically "
"set to true by a handler and that the data received is buffered."), "set to true by a handler and that the data received is buffered."),
Name = name(),
Fun = case config(ref, Config0) of Fun = case config(ref, Config0) of
https_compress -> init_https; https_compress -> init_https;
h2_compress -> init_http2; h2_compress -> init_http2;
_ -> init_http _ -> init_http
end, end,
Config = cowboy_test:Fun(Name, #{ Config = cowboy_test:Fun(?FUNCTION_NAME, #{
env => #{dispatch => init_dispatch(Config0)}, env => #{dispatch => init_dispatch(Config0)},
stream_handlers => [cowboy_compress_h, cowboy_stream_h], stream_handlers => [cowboy_compress_h, cowboy_stream_h],
compress_buffering => false compress_buffering => false
@ -267,7 +262,7 @@ set_options_compress_buffering_true(Config0) ->
<<>> = iolist_to_binary(zlib:inflate(Z, Data1)), <<>> = iolist_to_binary(zlib:inflate(Z, Data1)),
gun:close(ConnPid) gun:close(ConnPid)
after after
cowboy:stop_listener(Name) cowboy:stop_listener(?FUNCTION_NAME)
end. end.
set_options_compress_threshold_0(Config) -> set_options_compress_threshold_0(Config) ->

View file

@ -19,7 +19,6 @@
-import(ct_helper, [config/2]). -import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]). -import(ct_helper, [doc/1]).
-import(ct_helper, [get_remote_pid_tcp/1]). -import(ct_helper, [get_remote_pid_tcp/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]). -import(cowboy_test, [gun_open/1]).
all() -> [{group, clear}]. all() -> [{group, clear}].
@ -57,8 +56,8 @@ idle_timeout(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 1000 idle_timeout => 1000
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]), {ok, Socket} = do_handshake([{port, Port}|Config]),
timer:sleep(1000), timer:sleep(1000),
%% Receive a GOAWAY frame back with NO_ERROR. %% Receive a GOAWAY frame back with NO_ERROR.
@ -71,8 +70,8 @@ idle_timeout_infinity(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => infinity idle_timeout => infinity
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]), {ok, Socket} = do_handshake([{port, Port}|Config]),
timer:sleep(1000), timer:sleep(1000),
%% Don't receive a GOAWAY frame. %% Don't receive a GOAWAY frame.
@ -85,8 +84,8 @@ idle_timeout_reset_on_data(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 1000 idle_timeout => 1000
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]), {ok, Socket} = do_handshake([{port, Port}|Config]),
%% We wait a little, send a PING, receive a PING ack. %% We wait a little, send a PING, receive a PING ack.
{error, timeout} = gen_tcp:recv(Socket, 17, 500), {error, timeout} = gen_tcp:recv(Socket, 17, 500),
@ -111,8 +110,8 @@ inactivity_timeout(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
inactivity_timeout => 1000 inactivity_timeout => 1000
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]), {ok, Socket} = do_handshake([{port, Port}|Config]),
receive after 1000 -> ok end, receive after 1000 -> ok end,
%% Receive a GOAWAY frame back with an INTERNAL_ERROR. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
initial_connection_window_size => ConfiguredSize initial_connection_window_size => ConfiguredSize
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}]), {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}]),
%% Send a valid preface. %% Send a valid preface.
ok = gen_tcp:send(Socket, ["PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", cow_http2:settings(#{})]), 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
max_frame_size_sent => MaxFrameSize max_frame_size_sent => MaxFrameSize
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake(#{max_frame_size => MaxFrameSize + 10000}, [{port, Port}|Config]), {ok, Socket} = do_handshake(#{max_frame_size => MaxFrameSize + 10000}, [{port, Port}|Config]),
%% Send a request with a 30000 bytes body. %% Send a request with a 30000 bytes body.
{HeadersBlock, _} = cow_hpack:encode([ {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, <<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), {ok, <<10000:24, 0:8, _:40, _:10000/unit:8>>} = gen_tcp:recv(Socket, 10009, 6000),
%% Stop the listener. %% Stop the listener.
cowboy:stop_listener(name()). cowboy:stop_listener(?FUNCTION_NAME).
preface_timeout_infinity(Config) -> preface_timeout_infinity(Config) ->
doc("Ensure infinity for preface_timeout is accepted."), doc("Ensure infinity for preface_timeout is accepted."),
@ -186,8 +185,8 @@ preface_timeout_infinity(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
preface_timeout => infinity preface_timeout => infinity
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]), {ok, Socket} = do_handshake([{port, Port}|Config]),
Pid = get_remote_pid_tcp(Socket), Pid = get_remote_pid_tcp(Socket),
Ref = erlang:monitor(process, Pid), Ref = erlang:monitor(process, Pid),
@ -195,7 +194,7 @@ preface_timeout_infinity(Config) ->
{'DOWN', Ref, process, Pid, Reason} -> {'DOWN', Ref, process, Pid, Reason} ->
error(Reason) error(Reason)
after 1000 -> after 1000 ->
cowboy:stop_listener(name()) cowboy:stop_listener(?FUNCTION_NAME)
end. end.
resp_iolist_body(Config) -> resp_iolist_body(Config) ->
@ -205,8 +204,8 @@ resp_iolist_body(Config) ->
ProtoOpts = #{ ProtoOpts = #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))} env => #{dispatch => cowboy_router:compile(init_routes(Config))}
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http2}, {port, Port}|Config]), ConnPid = gun_open([{type, tcp}, {protocol, http2}, {port, Port}|Config]),
Ref = gun:get(ConnPid, "/resp_iolist_body"), Ref = gun:get(ConnPid, "/resp_iolist_body"),
{response, nofin, 200, RespHeaders} = gun:await(ConnPid, Ref), {response, nofin, 200, RespHeaders} = gun:await(ConnPid, Ref),
@ -222,8 +221,8 @@ settings_timeout_infinity(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
settings_timeout => infinity settings_timeout => infinity
}, },
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
{ok, Socket} = do_handshake([{port, Port}|Config]), {ok, Socket} = do_handshake([{port, Port}|Config]),
Pid = get_remote_pid_tcp(Socket), Pid = get_remote_pid_tcp(Socket),
Ref = erlang:monitor(process, Pid), Ref = erlang:monitor(process, Pid),
@ -231,5 +230,5 @@ settings_timeout_infinity(Config) ->
{'DOWN', Ref, process, Pid, Reason} -> {'DOWN', Ref, process, Pid, Reason} ->
error(Reason) error(Reason)
after 1000 -> after 1000 ->
cowboy:stop_listener(name()) cowboy:stop_listener(?FUNCTION_NAME)
end. end.

View file

@ -19,7 +19,6 @@
-import(ct_helper, [config/2]). -import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]). -import(ct_helper, [doc/1]).
-import(ct_helper, [get_remote_pid_tcp/1]). -import(ct_helper, [get_remote_pid_tcp/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]). -import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [raw_open/1]). -import(cowboy_test, [raw_open/1]).
-import(cowboy_test, [raw_send/2]). -import(cowboy_test, [raw_send/2]).
@ -43,11 +42,11 @@ init_routes(_) -> [
chunked_false(Config) -> chunked_false(Config) ->
doc("Confirm the option chunked => false disables chunked " doc("Confirm the option chunked => false disables chunked "
"transfer-encoding for HTTP/1.1 connections."), "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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => false 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", 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]), Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request), ok = raw_send(Client, Request),
@ -69,11 +68,11 @@ chunked_false(Config) ->
http10_keepalive_false(Config) -> http10_keepalive_false(Config) ->
doc("Confirm the option http10_keepalive => false disables keep-alive " doc("Confirm the option http10_keepalive => false disables keep-alive "
"completely for HTTP/1.0 connections."), "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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
http10_keepalive => false 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", 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]), Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Keepalive), ok = raw_send(Client, Keepalive),
@ -93,12 +92,12 @@ http10_keepalive_false(Config) ->
idle_timeout_infinity(Config) -> idle_timeout_infinity(Config) ->
doc("Ensure the idle_timeout option accepts the infinity value."), 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
request_timeout => 500, request_timeout => 500,
idle_timeout => infinity idle_timeout => infinity
}), }),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]), ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/echo/read_body", _ = gun:post(ConnPid, "/echo/read_body",
[{<<"content-type">>, <<"text/plain">>}]), [{<<"content-type">>, <<"text/plain">>}]),
@ -114,11 +113,11 @@ idle_timeout_infinity(Config) ->
request_timeout_infinity(Config) -> request_timeout_infinity(Config) ->
doc("Ensure the request_timeout option accepts the infinity value."), 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => infinity idle_timeout => infinity
}), }),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]), ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
#{socket := Socket} = gun:info(ConnPid), #{socket := Socket} = gun:info(ConnPid),
Pid = get_remote_pid_tcp(Socket), 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 " doc("Confirm the option chunked can be dynamically set to disable "
"chunked transfer-encoding. This results in the closing of the " "chunked transfer-encoding. This results in the closing of the "
"connection after the current request."), "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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => true 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", 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]), Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request), 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 " doc("Confirm the option chunked can be dynamically set to disable "
"chunked transfer-encoding, and that it is ignored if the " "chunked transfer-encoding, and that it is ignored if the "
"response is not streamed."), "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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => true chunked => true
}), }),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]), ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
%% We do a first request setting the option but not %% We do a first request setting the option but not
%% using chunked transfer-encoding in the response. %% 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 " doc("Confirm that the idle_timeout option can be dynamically "
"set to change how long Cowboy will wait before it closes the connection."), "set to change how long Cowboy will wait before it closes the connection."),
%% We start with a long timeout and then cut it short. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 60000 idle_timeout => 60000
}), }),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]), ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/set_options/idle_timeout_short", _ = gun:post(ConnPid, "/set_options/idle_timeout_short",
[{<<"content-type">>, <<"text/plain">>}]), [{<<"content-type">>, <<"text/plain">>}]),
@ -202,11 +201,11 @@ set_options_idle_timeout(Config) ->
set_options_idle_timeout_only_applies_to_current_request(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."), 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. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 500 idle_timeout => 500
}), }),
Port = ranch:get_port(name()), Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]), ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
StreamRef = gun:post(ConnPid, "/set_options/idle_timeout_long", StreamRef = gun:post(ConnPid, "/set_options/idle_timeout_long",
[{<<"content-type">>, <<"text/plain">>}]), [{<<"content-type">>, <<"text/plain">>}]),
@ -239,8 +238,8 @@ switch_protocol_flush(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
stream_handlers => [switch_protocol_flush_h] stream_handlers => [switch_protocol_flush_h]
}, },
{ok, _} = cowboy:start_clear(switch_protocol_flush, [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
Port = ranch:get_port(switch_protocol_flush), Port = ranch:get_port(?FUNCTION_NAME),
Self = self(), Self = self(),
ConnPid = gun_open([{port, Port}, {type, tcp}, {protocol, http}|Config]), ConnPid = gun_open([{port, Port}, {type, tcp}, {protocol, http}|Config]),
_ = gun:get(ConnPid, "/", [ _ = gun:get(ConnPid, "/", [

View file

@ -18,7 +18,6 @@
-import(ct_helper, [config/2]). -import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]). -import(ct_helper, [doc/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]). -import(cowboy_test, [gun_open/1]).
all() -> all() ->
@ -80,13 +79,13 @@ router_invalid_path(Config) ->
set_env(Config0) -> set_env(Config0) ->
doc("Live replace a middleware environment value."), doc("Live replace a middleware environment value."),
Config = cowboy_test:init_http(name(), #{ Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => []} env => #{dispatch => []}
}, Config0), }, Config0),
ConnPid1 = gun_open(Config), ConnPid1 = gun_open(Config),
Ref1 = gun:get(ConnPid1, "/"), Ref1 = gun:get(ConnPid1, "/"),
{response, _, 400, _} = gun:await(ConnPid1, Ref1), {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. %% Only new connections get the updated environment.
ConnPid2 = gun_open(Config), ConnPid2 = gun_open(Config),
Ref2 = gun:get(ConnPid2, "/"), Ref2 = gun:get(ConnPid2, "/"),
@ -95,11 +94,11 @@ set_env(Config0) ->
set_env_missing(Config0) -> set_env_missing(Config0) ->
doc("Live replace a middleware environment value when env was not provided."), 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), ConnPid1 = gun_open(Config),
Ref1 = gun:get(ConnPid1, "/"), Ref1 = gun:get(ConnPid1, "/"),
{response, _, 500, _} = gun:await(ConnPid1, Ref1), {response, _, 500, _} = gun:await(ConnPid1, Ref1),
cowboy:set_env(name(), dispatch, []), cowboy:set_env(?FUNCTION_NAME, dispatch, []),
%% Only new connections get the updated environment. %% Only new connections get the updated environment.
ConnPid2 = gun_open(Config), ConnPid2 = gun_open(Config),
Ref2 = gun:get(ConnPid2, "/"), Ref2 = gun:get(ConnPid2, "/"),

View file

@ -17,7 +17,6 @@
-compile(nowarn_export_all). -compile(nowarn_export_all).
-import(ct_helper, [doc/1]). -import(ct_helper, [doc/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]). -import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [gun_down/1]). -import(cowboy_test, [gun_down/1]).
-import(cowboy_test, [raw_open/1]). -import(cowboy_test, [raw_open/1]).
@ -1591,7 +1590,7 @@ reject_absolute_form_different_host(Config) ->
empty_host(Config0) -> empty_host(Config0) ->
doc("The host header is empty when the authority component is undefined. (RFC7230 5.4)"), doc("The host header is empty when the authority component is undefined. (RFC7230 5.4)"),
Routes = [{'_', [{"/echo/:key[/:arg]", echo_h, []}]}], 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)} env => #{dispatch => cowboy_router:compile(Routes)}
}, Config0), }, Config0),
#{code := 200, body := <<>>} = do_raw(Config, [ #{code := 200, body := <<>>} = do_raw(Config, [
@ -1602,7 +1601,7 @@ empty_host(Config0) ->
"GET /echo/host HTTP/1.1\r\n" "GET /echo/host HTTP/1.1\r\n"
"Host: \r\n" "Host: \r\n"
"\r\n"]), "\r\n"]),
cowboy:stop_listener(name()). cowboy:stop_listener(?FUNCTION_NAME).
%% The effective request URI can be rebuilt by concatenating scheme, %% The effective request URI can be rebuilt by concatenating scheme,
%% "://", authority, path and query components. (RFC7230 5.5) %% "://", authority, path and query components. (RFC7230 5.5)

View file

@ -18,7 +18,6 @@
-import(ct_helper, [config/2]). -import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]). -import(ct_helper, [doc/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]). -import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [raw_open/1]). -import(cowboy_test, [raw_open/1]).
-import(cowboy_test, [raw_send/2]). -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 " doc("An endpoint that sets SETTINGS_MAX_FRAME_SIZE must allow frames "
"of up to that size. (RFC7540 4.2, RFC7540 6.5.2)"), "of up to that size. (RFC7540 4.2, RFC7540 6.5.2)"),
%% Create a new listener that sets the maximum frame size to 30000. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_frame_size_received => 30000 max_frame_size_received => 30000
}, Config0), }, Config0),
@ -1348,13 +1347,13 @@ max_frame_size_allow_exactly_custom(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000), {ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of a 25000 bytes frame. %% No errors follow due to our sending of a 25000 bytes frame.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000), {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) -> max_frame_size_reject_larger_than_custom(Config0) ->
doc("An endpoint that sets SETTINGS_MAX_FRAME_SIZE must reject frames " 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)"), "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. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_frame_size_received => 30000 max_frame_size_received => 30000
}, Config0), }, Config0),
@ -1375,7 +1374,7 @@ max_frame_size_reject_larger_than_custom(Config0) ->
]), ]),
%% Receive a FRAME_SIZE_ERROR connection error. %% Receive a FRAME_SIZE_ERROR connection error.
{ok, << _:24, 7:8, _:72, 6:32 >>} = gen_tcp:recv(Socket, 17, 6000), {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 %% 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 %% 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)"), "used by the server to decode header blocks. (RFC7540 6.5.2)"),
HeaderTableSize = 128, HeaderTableSize = 128,
%% Create a new listener that allows larger header table sizes. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_decode_table_size => HeaderTableSize max_decode_table_size => HeaderTableSize
}, Config0), }, Config0),
@ -2589,13 +2588,13 @@ settings_header_table_size_server(Config0) ->
{_, <<"200">>} = lists:keyfind(<<":status">>, 1, RespHeaders), {_, <<"200">>} = lists:keyfind(<<":status">>, 1, RespHeaders),
%% The decoding succeeded on the server, confirming that %% The decoding succeeded on the server, confirming that
%% the table size was updated to HeaderTableSize. %% the table size was updated to HeaderTableSize.
cowboy:stop_listener(name()). cowboy:stop_listener(?FUNCTION_NAME).
settings_max_concurrent_streams(Config0) -> settings_max_concurrent_streams(Config0) ->
doc("The SETTINGS_MAX_CONCURRENT_STREAMS setting can be used to " 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)"), "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. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_concurrent_streams => 1 max_concurrent_streams => 1
}, Config0), }, Config0),
@ -2615,13 +2614,13 @@ settings_max_concurrent_streams(Config0) ->
]), ]),
%% Receive a REFUSED_STREAM stream error. %% Receive a REFUSED_STREAM stream error.
{ok, << _:24, 3:8, _:8, 3:32, 7:32 >>} = gen_tcp:recv(Socket, 13, 6000), {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) -> settings_max_concurrent_streams_0(Config0) ->
doc("The SETTINGS_MAX_CONCURRENT_STREAMS setting can be set to " 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)"), "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. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_concurrent_streams => 0 max_concurrent_streams => 0
}, Config0), }, Config0),
@ -2636,7 +2635,7 @@ settings_max_concurrent_streams_0(Config0) ->
ok = gen_tcp:send(Socket, cow_http2:headers(1, fin, HeadersBlock)), ok = gen_tcp:send(Socket, cow_http2:headers(1, fin, HeadersBlock)),
%% Receive a REFUSED_STREAM stream error. %% Receive a REFUSED_STREAM stream error.
{ok, << _:24, 3:8, _:8, 1:32, 7:32 >>} = gen_tcp:recv(Socket, 13, 6000), {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) %% @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 " doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to "
"change the initial window size of streams. (RFC7540 6.5.2)"), "change the initial window size of streams. (RFC7540 6.5.2)"),
%% Create a new listener that sets initial window sizes to 100000. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_connection_window_size => 100000, initial_connection_window_size => 100000,
initial_stream_window_size => 100000 initial_stream_window_size => 100000
@ -2701,14 +2700,14 @@ settings_initial_window_size(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000), {ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of more than 65535 bytes of data. %% No errors follow due to our sending of more than 65535 bytes of data.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000), {error, timeout} = gen_tcp:recv(Socket, 0, 1000),
cowboy:stop_listener(name()). cowboy:stop_listener(?FUNCTION_NAME).
settings_initial_window_size_after_ack(Config0) -> settings_initial_window_size_after_ack(Config0) ->
doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to " doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to "
"change the initial window size of streams. It is applied " "change the initial window size of streams. It is applied "
"to all existing streams upon receipt of the SETTINGS ack. (RFC7540 6.5.2)"), "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. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_stream_window_size => 0 initial_stream_window_size => 0
}, Config0), }, Config0),
@ -2741,14 +2740,14 @@ settings_initial_window_size_after_ack(Config0) ->
]), ]),
%% Receive a FLOW_CONTROL_ERROR stream error. %% Receive a FLOW_CONTROL_ERROR stream error.
{ok, << _:24, 3:8, _:8, 1:32, 3:32 >>} = gen_tcp:recv(Socket, 13, 6000), {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) -> settings_initial_window_size_before_ack(Config0) ->
doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to " doc("The SETTINGS_INITIAL_WINDOW_SIZE setting can be used to "
"change the initial window size of streams. It is only " "change the initial window size of streams. It is only "
"applied upon receipt of the SETTINGS ack. (RFC7540 6.5.2)"), "applied upon receipt of the SETTINGS ack. (RFC7540 6.5.2)"),
%% Create a new listener that sets the initial stream window sizes to 0. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_stream_window_size => 0 initial_stream_window_size => 0
}, Config0), }, Config0),
@ -2786,13 +2785,13 @@ settings_initial_window_size_before_ack(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000), {ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of more than 0 bytes of data. %% No errors follow due to our sending of more than 0 bytes of data.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000), {error, timeout} = gen_tcp:recv(Socket, 0, 1000),
cowboy:stop_listener(name()). cowboy:stop_listener(?FUNCTION_NAME).
settings_max_frame_size(Config0) -> settings_max_frame_size(Config0) ->
doc("The SETTINGS_MAX_FRAME_SIZE setting can be used to " doc("The SETTINGS_MAX_FRAME_SIZE setting can be used to "
"change the maximum frame size allowed. (RFC7540 6.5.2)"), "change the maximum frame size allowed. (RFC7540 6.5.2)"),
%% Create a new listener that sets the maximum frame size to 30000. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
max_frame_size_received => 30000 max_frame_size_received => 30000
}, Config0), }, Config0),
@ -2816,7 +2815,7 @@ settings_max_frame_size(Config0) ->
{ok, _} = gen_tcp:recv(Socket, Len2, 6000), {ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of a 25000 bytes frame. %% No errors follow due to our sending of a 25000 bytes frame.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000), {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) -> settings_max_frame_size_reject_too_small(Config) ->
doc("A SETTINGS_MAX_FRAME_SIZE smaller than 16384 must be rejected " 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 " "to overflow must be rejected with a FLOW_CONTROL_ERROR "
"connection error. (RFC7540 6.9.1)"), "connection error. (RFC7540 6.9.1)"),
%% Create a new listener that allows only a single concurrent stream. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_stream_window_size => 100000 initial_stream_window_size => 100000
}, Config0), }, Config0),
@ -3037,14 +3036,14 @@ data_reject_overflow(Config0) ->
]), ]),
%% Receive a FLOW_CONTROL_ERROR connection error. %% Receive a FLOW_CONTROL_ERROR connection error.
{ok, << _:24, 7:8, _:72, 3:32 >>} = gen_tcp:recv(Socket, 17, 6000), {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) -> data_reject_overflow_stream(Config0) ->
doc("DATA frames that cause the stream flow control window " doc("DATA frames that cause the stream flow control window "
"to overflow must be rejected with a FLOW_CONTROL_ERROR " "to overflow must be rejected with a FLOW_CONTROL_ERROR "
"stream error. (RFC7540 6.9.1)"), "stream error. (RFC7540 6.9.1)"),
%% Create a new listener that allows only a single concurrent stream. %% 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))}, env => #{dispatch => cowboy_router:compile(init_routes(Config0))},
initial_connection_window_size => 100000 initial_connection_window_size => 100000
}, Config0), }, Config0),
@ -3082,7 +3081,7 @@ data_reject_overflow_stream(Config0) ->
]), ]),
%% Receive a FLOW_CONTROL_ERROR stream error. %% Receive a FLOW_CONTROL_ERROR stream error.
{ok, << _:24, 3:8, _:8, 1:32, 3:32 >>} = gen_tcp:recv(Socket, 13, 6000), {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) %% (RFC7540 6.9.1)
% Frames with zero length with the END_STREAM flag set (that % Frames with zero length with the END_STREAM flag set (that