Class: HTTPX::Resolver::HTTPS
- Inherits:
-
Object
- Object
- HTTPX::Resolver::HTTPS
show all
- Extended by:
- Forwardable
- Includes:
- ResolverMixin
- Defined in:
- lib/httpx/resolver/https.rb
Constant Summary
collapse
- NAMESERVER =
"https://1.1.1.1/dns-query"
- RECORD_TYPES =
{
"A" => Resolv::DNS::Resource::IN::A,
"AAAA" => Resolv::DNS::Resource::IN::AAAA,
}.freeze
- DEFAULTS =
{
uri: NAMESERVER,
use_get: false,
}.freeze
ResolverMixin::CHECK_IF_IP
Constants included
from Loggable
Loggable::COLORS
Instance Method Summary
collapse
#uncache
Methods included from Loggable
#log, #log_exception
Methods included from Callbacks
#emit, #on, #once
Constructor Details
#initialize(options) ⇒ HTTPS
Returns a new instance of HTTPS.
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/httpx/resolver/https.rb', line 29
def initialize(options)
@options = Options.new(options)
@resolver_options = Resolver::Options.new(DEFAULTS.merge(@options.resolver_options || {}))
@_record_types = Hash.new { |types, host| types[host] = RECORD_TYPES.keys.dup }
@queries = {}
@requests = {}
@connections = []
@uri = URI(@resolver_options.uri)
@uri_addresses = nil
end
|
Instance Method Details
#<<(connection) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/httpx/resolver/https.rb', line 40
def <<(connection)
@uri_addresses ||= Resolv.getaddresses(@uri.host)
if @uri_addresses.empty?
ex = ResolveError.new("Can't resolve #{connection.origin.host}")
ex.set_backtrace(caller)
emit(:error, connection, ex)
else
early_resolve(connection) || resolve(connection)
end
end
|
#closed? ⇒ Boolean
55
56
57
58
59
|
# File 'lib/httpx/resolver/https.rb', line 55
def closed?
return true unless @resolver_connection
resolver_connection.closed?
end
|
#timeout ⇒ Object
51
52
53
|
# File 'lib/httpx/resolver/https.rb', line 51
def timeout
@connections.map(&:timeout).min
end
|