bugfix: do not resolve connection which are already resolved

connections which either already contain addresses, or were given an
open IO object, should be marked as resolved, and should not go through
the resolver.
This commit is contained in:
HoneyryderChuck 2021-03-08 12:42:32 +00:00
parent e8ac876443
commit 108837e25e

View File

@ -85,6 +85,20 @@ module HTTPX
def resolve_connection(connection)
@connections << connection unless @connections.include?(connection)
if connection.addresses || connection.state == :open
#
# there are two cases in which we want to activate initialization of
# connection immediately:
#
# 1. when the connection already has addresses, i.e. it doesn't need to
# resolve a name (not the same as name being an IP, yet)
# 2. when the connection is initialized with an external already open IO.
#
on_resolver_connection(connection)
return
end
resolver = find_resolver_for(connection)
resolver << connection
return if resolver.empty?