diff --git a/lib/httpx/extensions.rb b/lib/httpx/extensions.rb index 9660248e..e90e57dd 100644 --- a/lib/httpx/extensions.rb +++ b/lib/httpx/extensions.rb @@ -160,7 +160,6 @@ module HTTPX module URIExtensions # uri 0.11 backport, ships with ruby 3.1 refine URI::Generic do - public :set_host def non_ascii_hostname @non_ascii_hostname diff --git a/lib/httpx/io/udp.rb b/lib/httpx/io/udp.rb index 537ae2e3..ab58074a 100644 --- a/lib/httpx/io/udp.rb +++ b/lib/httpx/io/udp.rb @@ -6,11 +6,10 @@ module HTTPX class UDP include Loggable - def initialize(uri, _, options) - ip = IPAddr.new(uri.host) - @host = ip.to_s - @port = uri.port - @io = UDPSocket.new(ip.family) + def initialize(ip, port, options) + @host = ip + @port = port + @io = UDPSocket.new(IPAddr.new(ip).family) @options = options end diff --git a/lib/httpx/pool.rb b/lib/httpx/pool.rb index 122b8541..449541e6 100644 --- a/lib/httpx/pool.rb +++ b/lib/httpx/pool.rb @@ -132,9 +132,7 @@ module HTTPX def try_clone_connection(connection, family) connection.family ||= family - if connection.family == family - return connection - end + return connection if connection.family == family new_connection = connection.class.new(connection.type, connection.origin, connection.options) new_connection.family = family diff --git a/lib/httpx/resolver/native.rb b/lib/httpx/resolver/native.rb index 9de080fd..18f6366b 100644 --- a/lib/httpx/resolver/native.rb +++ b/lib/httpx/resolver/native.rb @@ -21,21 +21,7 @@ module HTTPX packet_size: 512, timeouts: Resolver::RESOLVE_TIMEOUT, } - end - - # nameservers for ipv6 are misconfigured in certain systems; - # this can use an unexpected endless loop - # https://gitlab.com/honeyryderchuck/httpx/issues/56 - DEFAULTS[:nameserver].select! do |nameserver| - begin - IPAddr.new(nameserver) - true - rescue IPAddr::InvalidAddressError - false - end - end if DEFAULTS[:nameserver] - - DEFAULTS.freeze + end.freeze DNS_PORT = 53 @@ -318,13 +304,8 @@ module HTTPX ip, port = @nameserver[@ns_index] port ||= DNS_PORT - uri = URI::Generic.build(scheme: "udp", port: port) - # uri.hostname = ip - # link-local IPv6 address may have a zone identifier, but URI does not support that yet. - uri.set_host(ip) - type = IO.registry(uri.scheme) - log { "resolver: server: #{uri}..." } - @io = type.new(uri, [IPAddr.new(ip)], @options) + log { "resolver: server: #{ip}:#{port}..." } + @io = UDP.new(ip, port, @options) end def transition(nextstate)