1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53: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

@@ -1,6 +1,6 @@
import json
from six.moves import urllib, xmlrpc_client
from .util import CaseInsensitiveDict, read_body
from .util import read_body
import logging
@@ -66,9 +66,8 @@ def _identity(x):
def _get_transformer(request):
headers = CaseInsensitiveDict(request.headers)
for checker, transformer in _checker_transformer_pairs:
if checker(headers): return transformer
if checker(request.headers): return transformer
else:
return _identity