aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-03-25 11:22:59 +0100
committerLoïc Hoguin <[email protected]>2020-03-25 11:22:59 +0100
commit2eaf28d3876c1ebcbf31d843e77f809e0c25aefb (patch)
tree1e93f66be05bc60bf27e5e5f30d31f44cfdac3eb /src/gun_http.erl
parent3deadc01ee34e27cfba49b78debcf8006d7d7e1c (diff)
downloadgun-2eaf28d3876c1ebcbf31d843e77f809e0c25aefb.tar.gz
gun-2eaf28d3876c1ebcbf31d843e77f809e0c25aefb.tar.bz2
gun-2eaf28d3876c1ebcbf31d843e77f809e0c25aefb.zip
Fix host/:authority header when connecting to an IPv6 address
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 401e23a..dd48c42 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -605,7 +605,8 @@ send_request(State=#http_state{socket=Socket, transport=Transport, version=Versi
host_header(Transport, Host0, Port) ->
Host = case Host0 of
{local, _SocketPath} -> <<>>;
- Tuple when is_tuple(Tuple) -> inet:ntoa(Tuple);
+ Tuple when tuple_size(Tuple) =:= 8 -> [$[, inet:ntoa(Tuple), $]]; %% IPv6.
+ Tuple when tuple_size(Tuple) =:= 4 -> inet:ntoa(Tuple); %% IPv4.
Atom when is_atom(Atom) -> atom_to_list(Atom);
_ -> Host0
end,