diff options
author | Loïc Hoguin <[email protected]> | 2020-03-25 11:22:59 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2020-03-25 11:22:59 +0100 |
commit | 2eaf28d3876c1ebcbf31d843e77f809e0c25aefb (patch) | |
tree | 1e93f66be05bc60bf27e5e5f30d31f44cfdac3eb /test/rfc7230_SUITE.erl | |
parent | 3deadc01ee34e27cfba49b78debcf8006d7d7e1c (diff) | |
download | gun-2eaf28d3876c1ebcbf31d843e77f809e0c25aefb.tar.gz gun-2eaf28d3876c1ebcbf31d843e77f809e0c25aefb.tar.bz2 gun-2eaf28d3876c1ebcbf31d843e77f809e0c25aefb.zip |
Fix host/:authority header when connecting to an IPv6 address
Diffstat (limited to 'test/rfc7230_SUITE.erl')
-rw-r--r-- | test/rfc7230_SUITE.erl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/rfc7230_SUITE.erl b/test/rfc7230_SUITE.erl index da7b426..d6afb2c 100644 --- a/test/rfc7230_SUITE.erl +++ b/test/rfc7230_SUITE.erl @@ -34,6 +34,19 @@ host_default_port_https(_) -> doc("The default port for https should not be sent in the host header. (RFC7230 2.7.2)"), do_host_port(tls, 443, <<>>). +host_ipv6(_) -> + doc("When connecting to a server using an IPv6 address the host " + "header must wrap the address with brackets. (RFC7230 5.4, RFC3986 3.2.2)"), + {ok, OriginPid, OriginPort} = init_origin(tcp, http), + {ok, ConnPid} = gun:open({0,0,0,0,0,0,0,1}, OriginPort, #{transport => tcp}), + {ok, http} = gun:await_up(ConnPid), + _ = gun:get(ConnPid, "/"), + handshake_completed = receive_from(OriginPid), + Data = receive_from(OriginPid), + Lines = binary:split(Data, <<"\r\n">>, [global]), + [<<"host: [::1]", _/bits>>] = [L || <<"host: ", _/bits>> = L <- Lines], + gun:close(ConnPid). + host_other_port_http(_) -> doc("Non-default ports for http must be sent in the host header. (RFC7230 2.7.1)"), do_host_port(tcp, 443, <<":443">>). |