aboutsummaryrefslogtreecommitdiffstats
path: root/test/http2_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2025-02-07 16:57:58 +0100
committerLoïc Hoguin <[email protected]>2025-02-07 17:59:44 +0100
commit0f257d06b6a4b1170621af66e9b54addf4d8e954 (patch)
treeab74e9cdb5418f1a8b489c06bd84bed9087a7fd6 /test/http2_SUITE.erl
parentd3f6bda38bedfdfef911cd5ba715c19be9b0408e (diff)
downloadcowboy-0f257d06b6a4b1170621af66e9b54addf4d8e954.tar.gz
cowboy-0f257d06b6a4b1170621af66e9b54addf4d8e954.tar.bz2
cowboy-0f257d06b6a4b1170621af66e9b54addf4d8e954.zip
Add hibernate option to cowboy_http and cowboy_http2
When enabled the connection process will automatically hibernate. Because hibernation triggers GC, this can be used as a way to keep memory usage lower, at the cost of performance.
Diffstat (limited to 'test/http2_SUITE.erl')
-rw-r--r--test/http2_SUITE.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/http2_SUITE.erl b/test/http2_SUITE.erl
index d3dc51a..f8c5a09 100644
--- a/test/http2_SUITE.erl
+++ b/test/http2_SUITE.erl
@@ -51,6 +51,27 @@ do_handshake(Settings, Config) ->
{ok, << 0:24, 4:8, 1:8, 0:32 >>} = gen_tcp:recv(Socket, 9, 1000),
{ok, Socket}.
+hibernate(Config) ->
+ doc("Ensure that we can enable hibernation for HTTP/1.1 connections."),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
+ env => #{dispatch => init_dispatch(Config)},
+ hibernate => true
+ }),
+ Port = ranch:get_port(?FUNCTION_NAME),
+ try
+ ConnPid = gun_open([{type, tcp}, {protocol, http2}, {port, Port}|Config]),
+ {ok, http2} = gun:await_up(ConnPid),
+ StreamRef1 = gun:get(ConnPid, "/"),
+ StreamRef2 = gun:get(ConnPid, "/"),
+ StreamRef3 = gun:get(ConnPid, "/"),
+ {response, nofin, 200, _} = gun:await(ConnPid, StreamRef1),
+ {response, nofin, 200, _} = gun:await(ConnPid, StreamRef2),
+ {response, nofin, 200, _} = gun:await(ConnPid, StreamRef3),
+ gun:close(ConnPid)
+ after
+ cowboy:stop_listener(?FUNCTION_NAME)
+ end.
+
idle_timeout(Config) ->
doc("Terminate when the idle timeout is reached."),
ProtoOpts = #{