mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-07 00:11:11 -04:00
Merge pull request #478 from jrafanie/dup_names_hash_when_copying_header_hash
Dup the @names hash when the Headers hash is copied.
This commit is contained in:
commit
ac73c46a78
@ -17,6 +17,12 @@ module Faraday
|
||||
self.update(hash || {})
|
||||
end
|
||||
|
||||
# on dup/clone, we need to duplicate @names hash
|
||||
def initialize_copy(other)
|
||||
super
|
||||
@names = other.names.dup
|
||||
end
|
||||
|
||||
# need to synchronize concurrent writes to the shared KeyMap
|
||||
keymap_mutex = Mutex.new
|
||||
|
||||
@ -102,6 +108,12 @@ module Faraday
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def names
|
||||
@names
|
||||
end
|
||||
end
|
||||
|
||||
# hash with stringified keys
|
||||
|
@ -200,6 +200,20 @@ class TestConnection < Faraday::TestCase
|
||||
assert_equal "http://sushi.com/nigiri?a=1&b=2&c=3", url.to_s
|
||||
end
|
||||
|
||||
def test_request_header_change_does_not_modify_connection_header
|
||||
connection = Faraday.new(:url => "https://asushi.com/sake.html")
|
||||
connection.headers = { "Authorization"=>"token abc123" }
|
||||
|
||||
request = connection.build_request(:get)
|
||||
request.headers.delete("Authorization")
|
||||
|
||||
assert_equal connection.headers.keys.sort, ["Authorization"]
|
||||
assert connection.headers.include?("Authorization")
|
||||
|
||||
assert_equal request.headers.keys.sort, []
|
||||
assert !request.headers.include?("Authorization")
|
||||
end
|
||||
|
||||
def test_env_url_parses_url_params_into_query
|
||||
uri = env_url("http://sushi.com/sake.html", 'a[b]' => '1 + 2')
|
||||
assert_equal "a%5Bb%5D=1+%2B+2", uri.query
|
||||
|
Loading…
x
Reference in New Issue
Block a user