aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2025-03-21 13:10:50 +0100
committerLoïc Hoguin <[email protected]>2025-03-21 13:10:50 +0100
commitdd1a09d7c8395d8e77d40a8bc5e1e4537c3c15b3 (patch)
tree3d5b39a82b96a0f27790d4f441f69f3fec424b63 /test
parent04c3436586eb150225791f96692eeff78f4d27c1 (diff)
downloadgun-respect-remote-concurrency-limit.tar.gz
gun-respect-remote-concurrency-limit.tar.bz2
gun-respect-remote-concurrency-limit.zip
Respect remote concurrency limit for headers/connect/ws_upgraderespect-remote-concurrency-limit
In order to simplify the implementation the CookieStore is given to the connect function now, even though it's not currently used.
Diffstat (limited to 'test')
-rw-r--r--test/rfc7540_SUITE.erl20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 6ac06d5..5bfa6cd 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -377,7 +377,19 @@ lingering_data_counts_toward_connection_window(_) ->
timer:sleep(300),
gun:close(ConnPid).
-max_concurrent_streams(_) ->
+max_concurrent_streams_headers(_) ->
+ do_max_concurrent_streams(post, "/").
+
+max_concurrent_streams_request(_) ->
+ do_max_concurrent_streams(get, "/").
+
+max_concurrent_streams_connect(_) ->
+ do_max_concurrent_streams(connect, #{host => "localhost", port => 33333}).
+
+max_concurrent_streams_ws_upgrade(_) ->
+ do_max_concurrent_streams(ws_upgrade, "/").
+
+do_max_concurrent_streams(Function, PathOrDestination) ->
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)"),
Ref = make_ref(),
@@ -397,9 +409,13 @@ max_concurrent_streams(_) ->
%% Wait for SETTINGS_MAX_CONCURRENT_STREAMS to be received by Gun.
receive {gun_notify, ConnPid, settings_changed, _} -> ok after 5000 -> error(timeout) end,
StreamRef1 = gun:get(ConnPid, "/delayed"),
- StreamRef2 = gun:get(ConnPid, "/delayed"),
+ %% Call the function we are currently testing.
+ %% Path doesn't matter as the request should not go through.
+ StreamRef2 = gun:Function(ConnPid, PathOrDestination, []),
+ %% Confirm we reached the concurrency limit.
{error, {stream_error, Reason}} = gun:await(ConnPid, StreamRef2),
{stream_error, too_many_streams, _Human} = Reason,
+ %% Confirm that the first request went through.
{response, nofin, 200, _} = gun:await(ConnPid, StreamRef1),
{ok, _} = gun:await_body(ConnPid, StreamRef1),
gun:close(ConnPid)