mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-01 00:01:03 -04:00
do not compare options objects by request-level options
This commit is contained in:
parent
6c1c1f5ee7
commit
a4d83103d2
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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(*)
|
||||
|
Loading…
x
Reference in New Issue
Block a user