rename system_resolve to hosts_resolve

to not confuse with the system resolver, which uses getaddrinfo
This commit is contained in:
HoneyryderChuck 2025-09-03 11:05:00 +01:00
parent 2fdfd7fb25
commit 71dd1e0840
4 changed files with 11 additions and 8 deletions

View File

@ -18,7 +18,7 @@ module HTTPX
@identifier_mutex = Thread::Mutex.new
@identifier = 1
@system_resolver = Resolv::Hosts.new
@hosts_resolver = Resolv::Hosts.new
module_function
@ -36,7 +36,7 @@ module HTTPX
end
def nolookup_resolve(hostname)
ip_resolve(hostname) || cached_lookup(hostname) || system_resolve(hostname)
ip_resolve(hostname) || cached_lookup(hostname) || hosts_resolve(hostname)
end
# tries to convert +hostname+ into an IPAddr, returns <tt>nil</tt> otherwise.
@ -47,8 +47,8 @@ module HTTPX
# matches +hostname+ to entries in the hosts file, returns <tt>nil</nil> if none is
# found, or there is no hosts file.
def system_resolve(hostname)
ips = @system_resolver.getaddresses(hostname)
def hosts_resolve(hostname)
ips = @hosts_resolver.getaddresses(hostname)
return if ips.empty?
ips.map { |ip| Entry.new(ip) }

View File

@ -13,7 +13,7 @@ module HTTPX
self.@lookups: Hash[String, Array[dns_result]]
self.@identifier_mutex: Thread::Mutex
self.@identifier: Integer
self.@system_resolver: Resolv::Hosts
self.@hosts_resolver: Resolv::Hosts
type dns_decoding_response = [:ok, Array[dns_result]] | [:decode_error, Resolv::DNS::DecodeError] | [:dns_error, Integer] | Symbol
@ -21,7 +21,7 @@ module HTTPX
def self?.ip_resolve: (String hostname) -> Array[Entry]?
def self?.system_resolve: (String hostname) -> Array[Entry]?
def self?.hosts_resolve: (String hostname) -> Array[Entry]?
def self?.resolver_for: (Symbol | singleton(Resolver) resolver_type, Options options) -> singleton(Resolver)

View File

@ -22,7 +22,6 @@ module HTTPX
@record_type: singleton(Resolv::DNS::Resource)
@resolver_options: Hash[Symbol, untyped]
@system_resolver: Resolv::Hosts
@connections: Array[Connection]
def close: () -> void

View File

@ -62,7 +62,7 @@ end
class WSCLient
extend Forwardable
def_delegator :@driver, :headers, :close
def_delegator :@driver, :headers
attr_reader :messages
@ -100,6 +100,10 @@ class WSCLient
@io.write(data)
end
def close
@driver.close
end
def finalize(_event)
@closed = true
end