]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 21 Sep 2024 23:28:59 +0000 (01:28 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 21 Sep 2024 23:33:15 +0000 (01:33 +0200)
- more fixed for handing parked domains (200 OK or 302 but no real content)

fba/http/network.py

index 15ca9d306a33f6ef6a05b1049f92ea81117e70e2..e95ef6a321ca9d09871faeff6ed161b736eaee29 100644 (file)
@@ -198,7 +198,12 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict:
         raise exception
 
     logger.debug("response.ok='%s',response.status_code=%d,response.reason='%s'", response.ok, response.status_code, response.reason)
-    if not json_helper.is_json_response(response):
+    if not response.ok or response.status_code > 200:
+        json_reply["status_code"]   = response.status_code
+        json_reply["error_message"] = f"response.ok='{response.ok}' or response.status_code={response.status_code} was not expected!"
+        logger.debug(json_reply["error_message"])
+    elif not json_helper.is_json_response(response):
+        logger.debug("content-type='%s' is not a valid JSON response!", response.headers.get("content-type"))
         json_reply["status_code"]   = 999
         json_reply["error_message"] = f"content-type='{response.headers.get('content-type')}' is not a JSON response!"
     elif response.ok and response.status_code == 200: