123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- -module(stream_handler_SUITE).
- -compile(export_all).
- -import(ct_helper, [config/2]).
- -import(ct_helper, [doc/1]).
- -import(cowboy_test, [gun_open/1]).
- all() ->
- cowboy_test:common_all().
- groups() ->
- cowboy_test:common_groups(ct_helper:all(?MODULE)).
- init_per_group(Name = http, Config) ->
- cowboy_test:init_http(Name, #{stream_handlers => [stream_handler_h]}, Config);
- init_per_group(Name = https, Config) ->
- cowboy_test:init_https(Name, #{stream_handlers => [stream_handler_h]}, Config);
- init_per_group(Name = h2, Config) ->
- cowboy_test:init_http2(Name, #{stream_handlers => [stream_handler_h]}, Config);
- init_per_group(Name = h2c, Config) ->
- Config1 = cowboy_test:init_http(Name, #{stream_handlers => [stream_handler_h]}, Config),
- lists:keyreplace(protocol, 1, Config1, {protocol, http2});
- init_per_group(Name = http_compress, Config) ->
- cowboy_test:init_http(Name, #{
- stream_handlers => [cowboy_compress_h, stream_handler_h]
- }, Config);
- init_per_group(Name = https_compress, Config) ->
- cowboy_test:init_https(Name, #{
- stream_handlers => [cowboy_compress_h, stream_handler_h]
- }, Config);
- init_per_group(Name = h2_compress, Config) ->
- cowboy_test:init_http2(Name, #{
- stream_handlers => [cowboy_compress_h, stream_handler_h]
- }, Config);
- init_per_group(Name = h2c_compress, Config) ->
- Config1 = cowboy_test:init_http(Name, #{
- stream_handlers => [cowboy_compress_h, stream_handler_h]
- }, Config),
- lists:keyreplace(protocol, 1, Config1, {protocol, http2}).
- end_per_group(Name, _) ->
- cowboy:stop_listener(Name).
- terminate_on_socket_close(Config) ->
- doc("Confirm terminate/3 is called when the socket gets closed brutally."),
- Self = self(),
- ConnPid = gun_open(Config),
- Ref = gun:get(ConnPid, "/long_polling", [
- {<<"accept-encoding">>, <<"gzip">>},
- {<<"x-test-case">>, <<"stream">>},
- {<<"x-test-pid">>, pid_to_list(Self)}
- ]),
-
- Pid = receive {Self, P, init, _, _, _} -> P after 1000 -> error(timeout) end,
- {response, nofin, 200, _} = gun:await(ConnPid, Ref),
-
- ok = gun:close(ConnPid),
-
- receive {Self, Pid, terminate, _, _, _} -> ok after 1000 -> error(timeout) end,
- ok.
|