From: Roland Häder Date: Tue, 25 Jul 2023 01:27:04 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cdcd2b0109e126bca887d0712a7ddf602e5d6e62;p=fba.git Continued: - request header is "Accept" - also need to send api_headers (ops) - need to convert variable 'path' to string --- diff --git a/fba/http/federation.py b/fba/http/federation.py index 895a509..5e490fc 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -283,8 +283,8 @@ def fetch_nodeinfo(domain: str, path: str = None) -> dict: for request in request_paths: logger.debug("request='%s'", request) - http_url = f"http://{domain}{path}" - https_url = f"https://{domain}{path}" + http_url = f"http://{domain}{str(path)}" + https_url = f"https://{domain}{str(path)}" logger.debug("path[%s]='%s',request='%s',http_url='%s',https_url='%s'", type(path), path, request, http_url, https_url) if path is None or path in [request, http_url, https_url]: diff --git a/fba/http/network.py b/fba/http/network.py index 390ba9f..0dfc424 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -39,8 +39,8 @@ web_headers = { # HTTP headers for API requests api_headers = { - "User-Agent" : config.get("useragent"), - "Content-Type": "application/json; charset=utf-8", + "User-Agent": config.get("useragent"), + "Accept" : "application/json; charset=utf-8", } # Exceptions to always catch @@ -161,7 +161,7 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict: try: logger.debug("Sending GET to domain='%s',path='%s',timeout(%d)='%s'", domain, path, len(timeout), timeout) - response = fetch_response(domain, path, headers, timeout) + response = fetch_response(domain, path, {**api_headers, **headers}, timeout) except exceptions as exception: logger.debug("Fetching path='%s' from domain='%s' failed. exception[%s]='%s'", path, domain, type(exception), str(exception)) json_reply["status_code"] = 999