|
@@ -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
|