]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 6 Aug 2023 05:05:04 +0000 (07:05 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Aug 2023 05:05:04 +0000 (07:05 +0200)
- ignore unsupported content type when response.text has zero length

fba/helpers/json.py

index 5f3fa1ab7251855b749c8915b9a51c338d6537d5..0905341ed118a48c95843dc4512c934d40d29d8b 100644 (file)
@@ -26,7 +26,7 @@ def from_response(response: requests.models.Response) -> any:
     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") is not None and response.headers.get("content-type").split(";")[0] not in ["*/*", "application/json", "application/jrd+json", "application/activity+json"]:
+    elif response.text.strip() != "" and response.headers.get("content-type") is not None and response.headers.get("content-type").split(";")[0] not in ["*/*", "application/json", "application/jrd+json", "application/activity+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()