Class: HTTPX::Resolver::System
- Inherits:
-
Object
- Object
- HTTPX::Resolver::System
show all
- Includes:
- ResolverMixin
- Defined in:
- lib/httpx/resolver/system.rb
Constant Summary
collapse
- RESOLV_ERRORS =
[Resolv::ResolvError,
Resolv::DNS::Requester::RequestError,
Resolv::DNS::EncodeError,
Resolv::DNS::DecodeError].freeze
ResolverMixin::CHECK_IF_IP
Constants included
from Loggable
Loggable::COLORS
Instance Method Summary
collapse
Methods included from Loggable
#log, #log_exception
Methods included from Callbacks
#emit, #on, #once
Constructor Details
#initialize(options) ⇒ System
Returns a new instance of System.
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/httpx/resolver/system.rb', line 15
def initialize(options)
@options = Options.new(options)
@resolver_options = Resolver::Options.new(@options.resolver_options)
@state = :idle
resolv_options = @resolver_options.to_h
timeouts = resolv_options.delete(:timeouts)
resolv_options.delete(:cache)
@resolver = Resolv::DNS.new(resolv_options.empty? ? nil : resolv_options)
@resolver.timeouts = timeouts if timeouts
end
|
Instance Method Details
#<<(connection) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/httpx/resolver/system.rb', line 34
def <<(connection)
hostname = connection.origin.host
addresses = connection.addresses ||
ip_resolve(hostname) ||
system_resolve(hostname) ||
@resolver.getaddresses(hostname)
throw(:resolve_error, resolve_error(hostname)) if addresses.empty?
emit_addresses(connection, addresses)
rescue Errno::EHOSTUNREACH, *RESOLV_ERRORS => e
emit_resolve_error(connection, hostname, e)
end
|
#closed? ⇒ Boolean
26
27
28
|
# File 'lib/httpx/resolver/system.rb', line 26
def closed?
true
end
|
#empty? ⇒ Boolean
30
31
32
|
# File 'lib/httpx/resolver/system.rb', line 30
def empty?
true
end
|
#uncache ⇒ Object
47
|
# File 'lib/httpx/resolver/system.rb', line 47
def uncache(*); end
|