lib/httpx/resolver/system.rb in httpx-0.3.1 vs lib/httpx/resolver/system.rb in httpx-0.4.0
- old
+ new
@@ -10,11 +10,11 @@
RESOLV_ERRORS = [Resolv::ResolvError,
Resolv::DNS::Requester::RequestError,
Resolv::DNS::EncodeError,
Resolv::DNS::DecodeError].freeze
- def initialize(_, options)
+ def initialize(options)
@options = Options.new(options)
roptions = @options.resolver_options
@state = :idle
@resolver = Resolv::DNS.new(roptions.nil? ? nil : roptions)
@resolver.timeouts = roptions[:timeouts] if roptions
@@ -26,16 +26,20 @@
def empty?
true
end
- def <<(channel)
- hostname = channel.uri.host
- addresses = ip_resolve(hostname) || system_resolve(hostname) || @resolver.getaddresses(hostname)
- return emit_resolve_error(channel, hostname) if addresses.empty?
- emit_addresses(channel, addresses)
+ def <<(connection)
+ hostname = connection.origin.host
+ addresses = connection.addresses ||
+ ip_resolve(hostname) ||
+ system_resolve(hostname) ||
+ @resolver.getaddresses(hostname)
+ return emit_resolve_error(connection, hostname) if addresses.empty?
+
+ emit_addresses(connection, addresses)
rescue Errno::EHOSTUNREACH, *RESOLV_ERRORS => e
- emit_resolve_error(channel, hostname, e)
+ emit_resolve_error(connection, hostname, e)
end
def uncache(*); end
end
end