From e1462eeadedca105659bd517734610513645682b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 26 Jun 2023 22:40:14 +0200 Subject: [PATCH] Continued: - strip of charset while checking for received content-type - but add it when sending it --- fba/http/network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fba/http/network.py b/fba/http/network.py index fdb5dcf..a910afd 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -40,7 +40,7 @@ web_headers = { # HTTP headers for API requests api_headers = { "User-Agent" : config.get("useragent"), - "Content-Type": "application/json", + "Content-Type": "application/json; charset=utf-8", } # Exceptions to always catch @@ -263,7 +263,7 @@ def json_from_response(response: requests.models.Response) -> list: logger.debug("response[]='%s' - CALLED!", type(response)) if not isinstance(response, requests.models.Response): raise ValueError(f"Parameter response[]='{type(response)}' is not type of 'Response'") - elif response.headers.get("content-type") != "application/json": + elif response.headers.get("content-type").split(";")[0] != "application/json": logger.warning("response.headers[content-type]='%s' is not a JSON type, below json() invocation may raise an exception", response.headers.get("content-type")) data = list() -- 2.39.5