0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Use try..after in tests that start their own listeners

This commit is contained in:
Loïc Hoguin 2018-11-19 09:29:21 +01:00
parent bed328b6c9
commit d2f367fba3
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
5 changed files with 631 additions and 524 deletions

View file

@ -1593,15 +1593,18 @@ empty_host(Config0) ->
Config = cowboy_test:init_http(?FUNCTION_NAME, #{
env => #{dispatch => cowboy_router:compile(Routes)}
}, Config0),
#{code := 200, body := <<>>} = do_raw(Config, [
"GET /echo/host HTTP/1.1\r\n"
"Host:\r\n"
"\r\n"]),
#{code := 200, body := <<>>} = do_raw(Config, [
"GET /echo/host HTTP/1.1\r\n"
"Host: \r\n"
"\r\n"]),
cowboy:stop_listener(?FUNCTION_NAME).
try
#{code := 200, body := <<>>} = do_raw(Config, [
"GET /echo/host HTTP/1.1\r\n"
"Host:\r\n"
"\r\n"]),
#{code := 200, body := <<>>} = do_raw(Config, [
"GET /echo/host HTTP/1.1\r\n"
"Host: \r\n"
"\r\n"])
after
cowboy:stop_listener(?FUNCTION_NAME)
end.
%% The effective request URI can be rebuilt by concatenating scheme,
%% "://", authority, path and query components. (RFC7230 5.5)