]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 26 Jun 2023 20:40:14 +0000 (22:40 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 26 Jun 2023 20:40:14 +0000 (22:40 +0200)
- strip of charset while checking for received content-type
- but add it when sending it

fba/http/network.py

index fdb5dcfce8d5b4950f1d77760ae72045532293ae..a910afd13570c68e4d8c2f85a5d8a507e7891bd7 100644 (file)
@@ -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()