mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
defining equality of options, using it to deduplicate connections as well
This commit is contained in:
parent
ca2e2523d9
commit
14e6619d92
@ -82,13 +82,13 @@ module HTTPX
|
||||
def match?(uri, options)
|
||||
return false if @state == :closing || @state == :closed
|
||||
|
||||
(@origins.include?(uri.origin) || match_altsvcs?(uri)) && connection_options_match?(options)
|
||||
(@origins.include?(uri.origin) || match_altsvcs?(uri)) && @options == options
|
||||
end
|
||||
|
||||
def mergeable?(connection)
|
||||
return false if @state == :closing || @state == :closed || !@io
|
||||
|
||||
!(@io.addresses & connection.addresses).empty? && connection_options_match?(connection.options)
|
||||
!(@io.addresses & connection.addresses).empty? && @options == connection.options
|
||||
end
|
||||
|
||||
# coalescable connections need to be mergeable!
|
||||
@ -368,12 +368,5 @@ module HTTPX
|
||||
request.emit(:response, @error_response)
|
||||
end
|
||||
end
|
||||
|
||||
def connection_options_match?(options)
|
||||
options.headers == @options.headers &&
|
||||
options.transport == @options.transport &&
|
||||
options.transport_options == @options.transport_options &&
|
||||
options.ssl == @options.ssl
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -108,6 +108,13 @@ module HTTPX
|
||||
def_option(method_name)
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
ivars = instance_variables | other.instance_variables
|
||||
ivars.all? do |ivar|
|
||||
instance_variable_get(ivar) == other.instance_variable_get(ivar)
|
||||
end
|
||||
end
|
||||
|
||||
def merge(other)
|
||||
h1 = to_hash
|
||||
h2 = other.to_hash
|
||||
|
Loading…
x
Reference in New Issue
Block a user