From 95f6279ad0159954d13d72d074a300db650db532 Mon Sep 17 00:00:00 2001 From: "fedor.fominyh" Date: Wed, 18 Oct 2023 15:38:35 +0400 Subject: [PATCH] Support charset=utf-8 in Content-Type header --- aio_request/base.py | 2 +- tests/test_base.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/aio_request/base.py b/aio_request/base.py index caa0c36..d705e67 100644 --- a/aio_request/base.py +++ b/aio_request/base.py @@ -37,7 +37,7 @@ class Header: collections.abc.Mapping[str | multidict.istr, str] | multidict.CIMultiDictProxy[str] | multidict.CIMultiDict[str] ) -json_re = re.compile(r"^application/(?:[\w.+-]+?\+)?json", re.RegexFlag.IGNORECASE) +json_re = re.compile(r"^application/(?:[\w.+-]+?\+)?json(;\w+charset\w+=\w+utf-8\w+)?", re.RegexFlag.IGNORECASE) PathParameters = collections.abc.Mapping[str, Any] QueryParameters = collections.abc.Mapping[str, Any] | collections.abc.Iterable[tuple[str, Any]] | _MultiDict diff --git a/tests/test_base.py b/tests/test_base.py index fdc0d26..0436d8c 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -25,6 +25,8 @@ async def test_extend_headers(): (False, "application/xml", "application/json"), (True, "application/json", "application/json"), (True, "application/problem+json", "application/json"), + (True, "application/problem+json;charset=uft-8", "application/json"), + (True, "application/problem+json; charset = uft-8 ", "application/json"), ], ) async def test_response_is_json(is_json: bool, response_content_type: str, content_type: str):