aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorSeudin Kasumovic <[email protected]>2018-05-04 21:10:44 +0200
committerLoïc Hoguin <[email protected]>2018-05-15 13:55:15 +0200
commit0cbdd2fc95e58b197909e313748d0870c05a8da7 (patch)
treee081868e3b3e756fdf4e4bcc23d462fd30e6a519 /src/gun_http.erl
parent6d5710c509548dfe0965d3c279b119978a3fc19d (diff)
downloadgun-0cbdd2fc95e58b197909e313748d0870c05a8da7.tar.gz
gun-0cbdd2fc95e58b197909e313748d0870c05a8da7.tar.bz2
gun-0cbdd2fc95e58b197909e313748d0870c05a8da7.zip
Allow IP tuple for host #152
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 6546df9..d6b3f0d 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -280,9 +280,13 @@ keepalive(State) ->
request(State=#http_state{socket=Socket, transport=Transport, version=Version,
out=head}, StreamRef, ReplyTo, Method, Host, Port, Path, Headers) ->
+ Host2 = case Host of
+ Tuple when is_tuple(Tuple) -> inet:ntoa(Tuple);
+ _ -> Host
+ end,
Headers2 = lists:keydelete(<<"transfer-encoding">>, 1, Headers),
Headers3 = case lists:keymember(<<"host">>, 1, Headers) of
- false -> [{<<"host">>, [Host, $:, integer_to_binary(Port)]}|Headers2];
+ false -> [{<<"host">>, [Host2, $:, integer_to_binary(Port)]}|Headers2];
true -> Headers2
end,
%% We use Headers2 because this is the smallest list.
@@ -299,10 +303,14 @@ request(State=#http_state{socket=Socket, transport=Transport, version=Version,
request(State=#http_state{socket=Socket, transport=Transport, version=Version,
out=head}, StreamRef, ReplyTo, Method, Host, Port, Path, Headers, Body) ->
+ Host2 = case Host of
+ Tuple when is_tuple(Tuple) -> inet:ntoa(Tuple);
+ _ -> Host
+ end,
Headers2 = lists:keydelete(<<"content-length">>, 1,
lists:keydelete(<<"transfer-encoding">>, 1, Headers)),
Headers3 = case lists:keymember(<<"host">>, 1, Headers) of
- false -> [{<<"host">>, [Host, $:, integer_to_binary(Port)]}|Headers2];
+ false -> [{<<"host">>, [Host2, $:, integer_to_binary(Port)]}|Headers2];
true -> Headers2
end,
Headers4 = transform_header_names(State, Headers3),