mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-07 00:11:11 -04:00
* Bootstrap method that fixes deserializing with YAML * YAML encoding of Header * Utils.rb: Avoid relying on the #names method
This commit is contained in:
parent
347d15b2ec
commit
0f17254d4a
@ -108,6 +108,14 @@ module Faraday
|
||||
}
|
||||
end
|
||||
|
||||
def init_with(coder)
|
||||
@names = coder['names']
|
||||
end
|
||||
|
||||
def encode_with(coder)
|
||||
coder['names'] = @names
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def names
|
||||
|
@ -63,5 +63,15 @@ class TestUtils < Faraday::TestCase
|
||||
Faraday::Utils.default_uri_parser = old_parser
|
||||
end
|
||||
end
|
||||
|
||||
# YAML parsing
|
||||
|
||||
def test_headers_yaml_roundtrip
|
||||
headers = Faraday::Utils::Headers.new('User-Agent' => 'safari', 'Content-type' => 'text/html')
|
||||
result = YAML.load(headers.to_yaml)
|
||||
|
||||
assert result.include?('user-agent'), 'Unable to hydrate to a correct Headers'
|
||||
assert result.include?('content-type'), 'Unable to hydrate to a correct Headers'
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user