class HTTPX::Resolver::HTTPS

  1. lib/httpx/resolver/https.rb
Superclass: Resolver

Methods

Public Class

  1. new

Public Instance

  1. <<
  2. closed?
  3. empty?
  4. resolver_connection

Constants

DEFAULTS = { uri: NAMESERVER, use_get: false, }.freeze  
NAMESERVER = "https://1.1.1.1/dns-query"  

Public Class methods

new(_, options)
[show source]
   # File lib/httpx/resolver/https.rb
32 def initialize(_, options)
33   super
34   @resolver_options = DEFAULTS.merge(@options.resolver_options)
35   @queries = {}
36   @requests = {}
37   @connections = []
38   @uri = URI(@resolver_options[:uri])
39   @uri_addresses = nil
40   @resolver = Resolv::DNS.new
41   @resolver.timeouts = @resolver_options.fetch(:timeouts, Resolver::RESOLVE_TIMEOUT)
42   @resolver.lazy_initialize
43 end

Public Instance methods

<<(connection)
[show source]
   # File lib/httpx/resolver/https.rb
45 def <<(connection)
46   return if @uri.origin == connection.origin.to_s
47 
48   @uri_addresses ||= HTTPX::Resolver.nolookup_resolve(@uri.host) || @resolver.getaddresses(@uri.host)
49 
50   if @uri_addresses.empty?
51     ex = ResolveError.new("Can't resolve DNS server #{@uri.host}")
52     ex.set_backtrace(caller)
53     connection.force_reset
54     throw(:resolve_error, ex)
55   end
56 
57   resolve(connection)
58 end
closed?()
[show source]
   # File lib/httpx/resolver/https.rb
60 def closed?
61   true
62 end
empty?()
[show source]
   # File lib/httpx/resolver/https.rb
64 def empty?
65   true
66 end
resolver_connection()
[show source]
   # File lib/httpx/resolver/https.rb
68 def resolver_connection
69   @resolver_connection ||= @pool.find_connection(@uri, @options) || begin
70     @building_connection = true
71     connection = @options.connection_class.new(@uri, @options.merge(ssl: { alpn_protocols: %w[h2] }))
72     @pool.init_connection(connection, @options)
73     # only explicity emit addresses if connection didn't pre-resolve, i.e. it's not an IP.
74     catch(:coalesced) do
75       @building_connection = false
76       emit_addresses(connection, @family, @uri_addresses) unless connection.addresses
77       connection
78     end
79   end
80 end