1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 09:13:23 +00:00

Make request.headers always a CaseInsensitiveDict.

Previously request.headers was a normal dict (albeit with the
request.add_header interface) which meant that some code paths would do
case-sensitive matching, for example remove_post_data_parameters which
tests for 'Content-Type'. This change allows all code paths to get the same
case-insensitive treatment.

Additionally request.headers becomes a property to enforce upgrading it to
a CaseInsensitiveDict even if assigned.
This commit is contained in:
Aron Griffis
2015-08-24 12:58:34 -04:00
parent efe6744eda
commit eda64bc3be
5 changed files with 24 additions and 21 deletions

View File

@@ -17,11 +17,7 @@ def _request_with_auth(url, username, password):
def _find_header(cassette, header):
for request in cassette.requests:
for k in request.headers:
if header.lower() == k.lower():
return True
return False
return any(header in request.headers for request in cassette.requests)
def test_filter_basic_auth(tmpdir):