diff options
author | Nelson Vides <[email protected]> | 2021-04-20 14:58:58 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2023-12-21 15:01:33 +0100 |
commit | 5ef64557b5b4c92224d68d1445cdb7846a76a0be (patch) | |
tree | a9bab5b54dc25b15de13708118645f69294c570c /test | |
parent | f74b69c3edd6e8c8891a3a8e18d14c8ae93bf5c4 (diff) | |
download | cowboy-5ef64557b5b4c92224d68d1445cdb7846a76a0be.tar.gz cowboy-5ef64557b5b4c92224d68d1445cdb7846a76a0be.tar.bz2 cowboy-5ef64557b5b4c92224d68d1445cdb7846a76a0be.zip |
Exit gracefully on {error,closed} when reading the PROXY header
LH: Simplified the test a little.
Diffstat (limited to 'test')
-rw-r--r-- | test/proxy_header_SUITE.erl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/proxy_header_SUITE.erl b/test/proxy_header_SUITE.erl index ce8b6cb..9d1ca2f 100644 --- a/test/proxy_header_SUITE.erl +++ b/test/proxy_header_SUITE.erl @@ -71,6 +71,30 @@ init_dispatch() -> %% Tests. +fail_gracefully_on_disconnect(Config) -> + doc("Probing a port must not generate a crash"), + {ok, Socket} = gen_tcp:connect("localhost", config(port, Config), + [binary, {active, false}, {packet, raw}]), + timer:sleep(50), + Pid = case config(type, Config) of + tcp -> ct_helper:get_remote_pid_tcp(Socket); + %% We connect to a TLS port using a TCP socket so we need + %% to first obtain the remote pid of the TCP socket, which + %% is a TLS socket on the server, and then get the real + %% remote pid from its state. + ssl -> ct_helper:get_remote_pid_tls_state(ct_helper:get_remote_pid_tcp(Socket)) + end, + Ref = erlang:monitor(process, Pid), + gen_tcp:close(Socket), + receive + {'DOWN', Ref, process, Pid, {shutdown, closed}} -> + ok; + {'DOWN', Ref, process, Pid, Reason} -> + error(Reason) + after 500 -> + error(timeout) + end. + v1_proxy_header(Config) -> doc("Confirm we can read the proxy header at the start of the connection."), ProxyInfo = #{ |