From 907c927d60f4ba3f09cf3574a5ae90ab76aa1717 Mon Sep 17 00:00:00 2001 From: Lucy Linder Date: Tue, 24 Jul 2018 18:13:50 +0200 Subject: [PATCH] make content-type's charset information case-insensitive see issue https://github.com/requests/requests/issues/4748 for more information --- requests/utils.py | 2 +- tests/test_utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/requests/utils.py b/requests/utils.py index 431f6be0..fd186b88 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -466,7 +466,7 @@ def _parse_content_type_header(header): if index_of_equals != -1: key = param[:index_of_equals].strip(items_to_strip) value = param[index_of_equals + 1:].strip(items_to_strip) - params_dict[key] = value + params_dict[key.lower()] = value return content_type, params_dict diff --git a/tests/test_utils.py b/tests/test_utils.py index f39cd67b..70ffa5fb 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -480,6 +480,10 @@ def test_parse_dict_header(value, expected): 'application/json ; charset=utf-8', ('application/json', {'charset': 'utf-8'}) ), + ( + 'application/json ; Charset=utf-8', + ('application/json', {'charset': 'utf-8'}) + ), ( 'text/plain', ('text/plain', {})