diff --git a/lib/httpx/connection.rb b/lib/httpx/connection.rb index 1a755756..20a80702 100644 --- a/lib/httpx/connection.rb +++ b/lib/httpx/connection.rb @@ -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 diff --git a/lib/httpx/options.rb b/lib/httpx/options.rb index 8c6ea955..5cb5623c 100644 --- a/lib/httpx/options.rb +++ b/lib/httpx/options.rb @@ -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