mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-12-07 00:00:31 -05:00
do not patch URI use for zone-identifier ipv6, instead do not use it
It was clarified in https://github.com/ruby/ipaddr/issues/52#issuecomment-1399289675 that there is no bug in `uri`, but rather that ipv6 addresses with zone-identifier aren't supposed to be used in uris.
This commit is contained in:
parent
a218463c73
commit
eb34c823f7
@ -160,7 +160,6 @@ module HTTPX
|
|||||||
module URIExtensions
|
module URIExtensions
|
||||||
# uri 0.11 backport, ships with ruby 3.1
|
# uri 0.11 backport, ships with ruby 3.1
|
||||||
refine URI::Generic do
|
refine URI::Generic do
|
||||||
public :set_host
|
|
||||||
|
|
||||||
def non_ascii_hostname
|
def non_ascii_hostname
|
||||||
@non_ascii_hostname
|
@non_ascii_hostname
|
||||||
|
|||||||
@ -6,11 +6,10 @@ module HTTPX
|
|||||||
class UDP
|
class UDP
|
||||||
include Loggable
|
include Loggable
|
||||||
|
|
||||||
def initialize(uri, _, options)
|
def initialize(ip, port, options)
|
||||||
ip = IPAddr.new(uri.host)
|
@host = ip
|
||||||
@host = ip.to_s
|
@port = port
|
||||||
@port = uri.port
|
@io = UDPSocket.new(IPAddr.new(ip).family)
|
||||||
@io = UDPSocket.new(ip.family)
|
|
||||||
@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -132,9 +132,7 @@ module HTTPX
|
|||||||
def try_clone_connection(connection, family)
|
def try_clone_connection(connection, family)
|
||||||
connection.family ||= family
|
connection.family ||= family
|
||||||
|
|
||||||
if connection.family == family
|
return connection if connection.family == family
|
||||||
return connection
|
|
||||||
end
|
|
||||||
|
|
||||||
new_connection = connection.class.new(connection.type, connection.origin, connection.options)
|
new_connection = connection.class.new(connection.type, connection.origin, connection.options)
|
||||||
new_connection.family = family
|
new_connection.family = family
|
||||||
|
|||||||
@ -21,21 +21,7 @@ module HTTPX
|
|||||||
packet_size: 512,
|
packet_size: 512,
|
||||||
timeouts: Resolver::RESOLVE_TIMEOUT,
|
timeouts: Resolver::RESOLVE_TIMEOUT,
|
||||||
}
|
}
|
||||||
end
|
end.freeze
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
DNS_PORT = 53
|
DNS_PORT = 53
|
||||||
|
|
||||||
@ -318,13 +304,8 @@ module HTTPX
|
|||||||
|
|
||||||
ip, port = @nameserver[@ns_index]
|
ip, port = @nameserver[@ns_index]
|
||||||
port ||= DNS_PORT
|
port ||= DNS_PORT
|
||||||
uri = URI::Generic.build(scheme: "udp", port: port)
|
log { "resolver: server: #{ip}:#{port}..." }
|
||||||
# uri.hostname = ip
|
@io = UDP.new(ip, port, @options)
|
||||||
# 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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def transition(nextstate)
|
def transition(nextstate)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user