diff options
Diffstat (limited to 'test/plain_handler_SUITE.erl')
-rw-r--r-- | test/plain_handler_SUITE.erl | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/test/plain_handler_SUITE.erl b/test/plain_handler_SUITE.erl index e980d5b..7684e6b 100644 --- a/test/plain_handler_SUITE.erl +++ b/test/plain_handler_SUITE.erl @@ -1,4 +1,4 @@ -%% Copyright (c) 2018, Loïc Hoguin <[email protected]> +%% Copyright (c) Loïc Hoguin <[email protected]> %% %% Permission to use, copy, modify, and/or distribute this software for any %% purpose with or without fee is hereby granted, provided that the above @@ -39,12 +39,13 @@ init_per_group(Name, Config) -> cowboy_test:init_common_groups(Name, Config, ?MODULE). end_per_group(Name, _) -> - cowboy:stop_listener(Name). + cowboy_test:stop_group(Name). %% Routes. init_dispatch(_) -> cowboy_router:compile([{"localhost", [ + {"/crash/external_exit", crash_h, external_exit}, {"/crash/no_reply", crash_h, no_reply}, {"/crash/reply", crash_h, reply} ]}]). @@ -58,8 +59,15 @@ crash_after_reply(Config) -> Ref = gun:get(ConnPid, "/crash/reply", [ {<<"accept-encoding">>, <<"gzip">>} ]), - {response, fin, 200, _} = gun:await(ConnPid, Ref), - {error, timeout} = gun:await(ConnPid, Ref, 1000), + Protocol = config(protocol, Config), + _ = case gun:await(ConnPid, Ref) of + {response, fin, 200, _} -> + {error, timeout} = gun:await(ConnPid, Ref, 1000); + %% See maybe_h3_error comment for details. + {error, {stream_error, {stream_error, h3_internal_error, _}}} + when Protocol =:= http3 -> + ok + end, gun:close(ConnPid). crash_before_reply(Config) -> @@ -71,3 +79,13 @@ crash_before_reply(Config) -> ]), {response, fin, 500, _} = gun:await(ConnPid, Ref), gun:close(ConnPid). + +external_exit_before_reply(Config) -> + doc("A plain handler exits externally before a response was sent " + "results in a 500 response."), + ConnPid = gun_open(Config), + Ref = gun:get(ConnPid, "/crash/external_exit", [ + {<<"accept-encoding">>, <<"gzip">>} + ]), + {response, fin, 500, _} = gun:await(ConnPid, Ref), + gun:close(ConnPid). |