Class: HTTPX::Resolver::System

Inherits:
Object
  • Object
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

Constants included from ResolverMixin

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
# File 'lib/httpx/resolver/system.rb', line 15

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
end

Instance Method Details

#<<(connection) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/httpx/resolver/system.rb', line 31

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(connection, hostname, e)
end

#closed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/httpx/resolver/system.rb', line 23

def closed?
  true
end

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/httpx/resolver/system.rb', line 27

def empty?
  true
end

#uncacheObject



44
# File 'lib/httpx/resolver/system.rb', line 44

def uncache(*); end