Skip to content

Commit bed3ae3

Browse files
committed
fix url parsing, handle IPs
1 parent 560d266 commit bed3ae3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/hackney.erl

+10-9
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,18 @@ request(Method, #hackney_url{}=URL0, Headers0, Body, Options0) ->
311311
URL = hackney_url:normalize(URL0, PathEncodeFun),
312312

313313
?report_trace("request", [{method, Method},
314-
{url, URL},
315-
{headers, Headers0},
316-
{body, Body},
317-
{options, Options0}]),
314+
{url, URL},
315+
{headers, Headers0},
316+
{body, Body},
317+
{options, Options0}]),
318318

319319
#hackney_url{transport=Transport,
320-
host = Host,
321-
port = Port,
322-
user = User,
323-
password = Password,
324-
scheme = Scheme} = URL,
320+
host = Host,
321+
port = Port,
322+
user = User,
323+
password = Password,
324+
scheme = Scheme} = URL,
325+
325326

326327
Options = case User of
327328
<<>> ->

src/hackney_happy.erl

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ getaddrs(Hostname) ->
4848
getbyname(Hostname, Type) ->
4949
case (catch inet_res:getbyname(Hostname, Type)) of
5050
{'ok', #hostent{h_addr_list=AddrList}} -> lists:usort(AddrList);
51+
{error, nxdomain} = Error ->
52+
case inet:parse_address(Hostname) of
53+
{ok, IP} -> [IP];
54+
_ -> Error
55+
end;
5156
{error, _Reason} -> [];
5257
Else ->
5358
%% ERLANG 22 has an issue when g matching somee DNS server messages

0 commit comments

Comments
 (0)