Pārlūkot izejas kodu

use is_ipv6_host/1 function from httpc

pull/165/head
getong pirms 6 gadiem
vecāks
revīzija
e733f7e038
1 mainītis faili ar 12 papildinājumiem un 5 dzēšanām
  1. +12
    -5
      src/ibrowse_http_client.erl

+ 12
- 5
src/ibrowse_http_client.erl Parādīt failu

@ -619,18 +619,25 @@ get_sock_options(Host, Options, SSLOptions) ->
[binary, {active, false} | Other_sock_options] [binary, {active, false} | Other_sock_options]
end. end.
%% copy from lhttpc_client.erl
is_ipv6_host(Host) -> is_ipv6_host(Host) ->
case inet_parse:address(Host) of case inet_parse:address(Host) of
{ok, {_, _, _, _, _, _, _, _}} -> {ok, {_, _, _, _, _, _, _, _}} ->
true; true;
{ok, {_, _, _, _}} -> {ok, {_, _, _, _}} ->
false; false;
_ ->
case inet:gethostbyname(Host, inet6) of
{ok, #hostent{h_addrtype = inet6}} ->
true;
_ ->
% Prefer IPv4 over IPv6.
case inet:getaddr(Host, inet) of
{ok, _} ->
false;
_ -> _ ->
false
case inet:getaddr(Host, inet6) of
{ok, _} ->
true;
_ ->
false
end
end end
end. end.

Notiek ielāde…
Atcelt
Saglabāt