]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 25 Jul 2023 01:27:04 +0000 (03:27 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 25 Jul 2023 01:27:04 +0000 (03:27 +0200)
- request header is "Accept"
- also need to send api_headers (ops)
- need to convert variable 'path' to string

fba/http/federation.py
fba/http/network.py

index 895a5090bb7c911263a04936a779224158dd9a4e..5e490fc81bcd1dfebba023340b8ed7ae2b3c5415 100644 (file)
@@ -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]:
index 390ba9ff1eb38144d05b0f74b656f8e622e2d2b4..0dfc4248fbb4a6e550fd626e28a50bced3493c31 100644 (file)
@@ -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