mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
fix: https resolver should close when no more outstanding connections are around
This commit is contained in:
parent
06b162b6ea
commit
82b0a4bf28
@ -25,6 +25,8 @@ require "mutex_m"
|
||||
# Top-Level Namespace
|
||||
#
|
||||
module HTTPX
|
||||
EMPTY = [].freeze
|
||||
|
||||
# All plugins should be stored under this module/namespace. Can register and load
|
||||
# plugins.
|
||||
#
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
module HTTPX
|
||||
class Headers
|
||||
EMPTY = [].freeze
|
||||
|
||||
class << self
|
||||
def new(headers = nil)
|
||||
return headers if headers.is_a?(self)
|
||||
|
@ -55,9 +55,19 @@ module HTTPX
|
||||
connections = connections.reject(&:inflight?)
|
||||
connections.each(&:close)
|
||||
next_tick until connections.none? { |c| c.state != :idle && @connections.include?(c) }
|
||||
@resolvers.each_value do |resolver|
|
||||
resolver.close unless resolver.closed?
|
||||
end if @connections.empty?
|
||||
|
||||
# close resolvers
|
||||
outstanding_connections = @connections
|
||||
resolver_connections = @resolvers.each_value.flat_map(&:connections).compact
|
||||
outstanding_connections -= resolver_connections
|
||||
if outstanding_connections.empty?
|
||||
@resolvers.each_value do |resolver|
|
||||
resolver.close unless resolver.closed?
|
||||
end
|
||||
# for https resolver
|
||||
resolver_connections.each(&:close)
|
||||
next_tick until resolver_connections.none? { |c| c.state != :idle && @connections.include?(c) }
|
||||
end
|
||||
end
|
||||
|
||||
def init_connection(connection, _options)
|
||||
|
@ -35,6 +35,10 @@ module HTTPX
|
||||
@resolvers.each(&:close)
|
||||
end
|
||||
|
||||
def connections
|
||||
@resolvers.filter_map { |r| r.resolver_connection if r.respond_to?(:resolver_connection) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def on_resolver_connection(connection)
|
||||
|
@ -22,6 +22,10 @@ module HTTPX
|
||||
@resolver.timeouts = timeouts || Resolver::RESOLVE_TIMEOUT
|
||||
end
|
||||
|
||||
def connections
|
||||
EMPTY
|
||||
end
|
||||
|
||||
def <<(connection)
|
||||
hostname = connection.origin.host
|
||||
addresses = connection.addresses ||
|
||||
|
@ -2,8 +2,6 @@ module HTTPX
|
||||
class Headers
|
||||
include _ToS
|
||||
|
||||
EMPTY: Array[untyped]
|
||||
|
||||
@headers: Hash[String, Array[String]]
|
||||
|
||||
def self.new: (?untyped headers) -> instance
|
||||
|
@ -1,6 +1,8 @@
|
||||
module HTTPX
|
||||
extend Chainable
|
||||
|
||||
EMPTY: Array[untyped]
|
||||
|
||||
VERSION: String
|
||||
|
||||
type uri = URI::HTTP | URI::HTTPS | string
|
||||
|
Loading…
x
Reference in New Issue
Block a user