1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +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

@@ -15,7 +15,7 @@ def vcr_fetch_impl(cassette, real_fetch_impl):
@functools.wraps(real_fetch_impl)
def new_fetch_impl(self, request, callback):
headers = dict(request.headers)
headers = request.headers.copy()
if request.user_agent:
headers.setdefault('User-Agent', request.user_agent)