mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-08 00:03:41 -04:00
Make dig method case-insensitive in Faraday::Utils::Headers
This commit is contained in:
parent
c0540b7ba3
commit
c9cc1b30ec
@ -77,6 +77,12 @@ module Faraday
|
||||
super(key)
|
||||
end
|
||||
|
||||
def dig(key, *rest)
|
||||
key = KeyMap[key]
|
||||
key = @names.fetch(key.downcase, key)
|
||||
super(key, *rest)
|
||||
end
|
||||
|
||||
def include?(key)
|
||||
@names.include? key.downcase
|
||||
end
|
||||
|
@ -56,6 +56,15 @@ RSpec.describe Faraday::Utils::Headers do
|
||||
it { expect(subject.delete('content-type')).to be_nil }
|
||||
end
|
||||
|
||||
describe '#dig' do
|
||||
before { subject['Content-Type'] = 'application/json' }
|
||||
|
||||
it { expect(subject&.dig('Content-Type')).to eq('application/json') }
|
||||
it { expect(subject&.dig('CONTENT-TYPE')).to eq('application/json') }
|
||||
it { expect(subject&.dig(:content_type)).to eq('application/json') }
|
||||
it { expect(subject&.dig('invalid')).to be_nil }
|
||||
end
|
||||
|
||||
describe '#parse' do
|
||||
context 'when response headers leave http status line out' do
|
||||
let(:headers) { "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user