1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- -module(http2_SUITE).
- -compile(export_all).
- -import(ct_helper, [config/2]).
- -import(ct_helper, [doc/1]).
- all() -> [{group, clear}].
- groups() -> [{clear, [parallel], ct_helper:all(?MODULE)}].
- init_routes(_) -> [
- {"localhost", [
- {"/", hello_h, []}
- ]}
- ].
- do_handshake(Config) ->
- {ok, Socket} = gen_tcp:connect("localhost", config(port, Config), [binary, {active, false}]),
-
- ok = gen_tcp:send(Socket, ["PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", cow_http2:settings(#{})]),
-
- {ok, << Len:24 >>} = gen_tcp:recv(Socket, 3, 1000),
- {ok, << 4:8, 0:40, _:Len/binary >>} = gen_tcp:recv(Socket, 6 + Len, 1000),
-
- ok = gen_tcp:send(Socket, cow_http2:settings_ack()),
-
- {ok, << 0:24, 4:8, 1:8, 0:32 >>} = gen_tcp:recv(Socket, 9, 1000),
- {ok, Socket}.
- inactivity_timeout(Config) ->
- doc("Terminate when the inactivity timeout is reached"),
- Ref = inactivity_timeout_listener,
- ProtoOpts = #{
- env => #{dispatch => cowboy_router:compile(init_routes(Config))},
- inactivity_timeout => 1000
- },
- {ok, _} = cowboy:start_clear(Ref, [{port, 0}], ProtoOpts),
- Port = ranch:get_port(Ref),
- SocketConfig = [{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config],
- {ok, Socket} = do_handshake(SocketConfig),
- receive after 1000 -> ok end,
-
- {ok, << _:24, 7:8, _:72, 2:32 >>} = gen_tcp:recv(Socket, 17, 1000),
- ok.
|