From 2eaf28d3876c1ebcbf31d843e77f809e0c25aefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Mar 2020 11:22:59 +0100 Subject: Fix host/:authority header when connecting to an IPv6 address --- src/gun_http.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gun_http.erl') 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, -- cgit v1.2.3