Skip to content

Commit

Permalink
fix url parsing, handle IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed May 28, 2024
1 parent 21b1b82 commit 75b8e72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/hackney.erl
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,18 @@ request(Method, #hackney_url{}=URL0, Headers0, Body, Options0) ->
URL = hackney_url:normalize(URL0, PathEncodeFun),

?report_trace("request", [{method, Method},
{url, URL},
{headers, Headers0},
{body, Body},
{options, Options0}]),
{url, URL},
{headers, Headers0},
{body, Body},
{options, Options0}]),

#hackney_url{transport=Transport,
host = Host,
port = Port,
user = User,
password = Password,
scheme = Scheme} = URL,
host = Host,
port = Port,
user = User,
password = Password,
scheme = Scheme} = URL,


Options = case User of
<<>> ->
Expand Down
5 changes: 5 additions & 0 deletions src/hackney_happy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ getaddrs(Hostname) ->
getbyname(Hostname, Type) ->
case (catch inet_res:getbyname(Hostname, Type)) of
{'ok', #hostent{h_addr_list=AddrList}} -> lists:usort(AddrList);
{error, nxdomain} = Error ->
case inet:parse_address(Hostname) of
{ok, IP} -> [IP];
_ -> Error
end;
{error, _Reason} -> [];
Else ->
%% ERLANG 22 has an issue when g matching somee DNS server messages
Expand Down

0 comments on commit 75b8e72

Please sign in to comment.