From: Roland Häder Date: Sat, 21 Sep 2024 23:28:59 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c2d8dcbc2afc9c9aeba3f728ab50f64d59a8247b;p=fba.git Continued: - more fixed for handing parked domains (200 OK or 302 but no real content) --- diff --git a/fba/http/network.py b/fba/http/network.py index 15ca9d3..e95ef6a 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -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: