mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
getheader() in stubs should be case-insensitive
This commit is contained in:
@@ -145,3 +145,7 @@ def test_session_and_connection_close(tmpdir, scheme):
|
|||||||
|
|
||||||
resp = session.get('http://httpbin.org/get', headers={'Connection': 'close'})
|
resp = session.get('http://httpbin.org/get', headers={'Connection': 'close'})
|
||||||
resp = session.get('http://httpbin.org/get', headers={'Connection': 'close'})
|
resp = session.get('http://httpbin.org/get', headers={'Connection': 'close'})
|
||||||
|
|
||||||
|
def test_https_with_cert_validation_disabled(tmpdir):
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('cert_validation_disabled.yaml'))):
|
||||||
|
requests.get('https://httpbin.org', verify=False)
|
||||||
|
|||||||
26
tests/integration/test_stubs.py
Normal file
26
tests/integration/test_stubs.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import vcr
|
||||||
|
import six.moves.http_client as httplib
|
||||||
|
|
||||||
|
def _headers_are_case_insensitive():
|
||||||
|
conn = httplib.HTTPConnection('httpbin.org')
|
||||||
|
conn.request('GET', "/cookies/set?k1=v1")
|
||||||
|
r1 = conn.getresponse()
|
||||||
|
cookie_data1 = r1.getheader('set-cookie')
|
||||||
|
conn = httplib.HTTPConnection('httpbin.org')
|
||||||
|
conn.request('GET', "/cookies/set?k1=v1")
|
||||||
|
r2 = conn.getresponse()
|
||||||
|
cookie_data2 = r2.getheader('Set-Cookie')
|
||||||
|
return cookie_data1 == cookie_data2
|
||||||
|
|
||||||
|
def test_case_insensitivity(tmpdir):
|
||||||
|
testfile = str(tmpdir.join('case_insensitivity.yml'))
|
||||||
|
# check if headers are case insensitive outside of vcrpy
|
||||||
|
outside = _headers_are_case_insensitive()
|
||||||
|
with vcr.use_cassette(testfile):
|
||||||
|
# check if headers are case insensitive inside of vcrpy
|
||||||
|
inside = _headers_are_case_insensitive()
|
||||||
|
# check if headers are case insensitive after vcrpy deserializes headers
|
||||||
|
inside2 = _headers_are_case_insensitive()
|
||||||
|
|
||||||
|
# behavior should be the same both inside and outside
|
||||||
|
assert outside == inside == inside2
|
||||||
@@ -111,8 +111,8 @@ class VCRHTTPResponse(HTTPResponse):
|
|||||||
return compat.get_header_items(message)
|
return compat.get_header_items(message)
|
||||||
|
|
||||||
def getheader(self, header, default=None):
|
def getheader(self, header, default=None):
|
||||||
headers = dict(((k, v) for k, v in self.getheaders()))
|
headers = dict(((k.lower(), v) for k, v in self.getheaders()))
|
||||||
return headers.get(header, default)
|
return headers.get(header.lower(), default)
|
||||||
|
|
||||||
|
|
||||||
class VCRConnection:
|
class VCRConnection:
|
||||||
|
|||||||
Reference in New Issue
Block a user