do not compare options objects by request-level options

This commit is contained in:
HoneyryderChuck 2019-09-27 12:37:45 +01:00
parent 6c1c1f5ee7
commit a4d83103d2
3 changed files with 24 additions and 1 deletions

View File

@ -41,6 +41,15 @@ module HTTPX
super
end
def same_headers?(headers)
@headers.empty? || begin
headers.each do |k, v|
return false unless v == self[k]
end
true
end
end
# merges headers with another header-quack.
# the merge rule is, if the header already exists,
# ignore what the +other+ headers has. Otherwise, set

View File

@ -108,10 +108,20 @@ module HTTPX
def_option(method_name)
end
REQUEST_IVARS = %i[@params @form @json @body].freeze
def ==(other)
ivars = instance_variables | other.instance_variables
ivars.all? do |ivar|
instance_variable_get(ivar) == other.instance_variable_get(ivar)
case ivar
when :@headers
headers = instance_variable_get(ivar)
headers.same_headers?(other.instance_variable_get(ivar))
when *REQUEST_IVARS
true
else
instance_variable_get(ivar) == other.instance_variable_get(ivar)
end
end
end

View File

@ -55,6 +55,10 @@ module HTTPX
end if @default_cookies
store
end
def ==(other)
@store == other.instance_variable_get(:@store)
end
end
def self.load_dependencies(*)