fetch well-known url for nodeinfo
[relay.git/.git] / relay / remote_actor.py
index faa0ced..279ada7 100644 (file)
@@ -12,13 +12,18 @@ CACHE_TTL = CONFIG.get('cache-ttl', 3600)
 ACTORS = TTLCache(CACHE_SIZE, CACHE_TTL)
 
 
-async def fetch_actor(uri, force=False):
+async def fetch_actor(uri, headers={}, force=False):
     if uri in ACTORS and not force:
         return ACTORS[uri]
 
+    new_headers = {'Accept': 'application/activity+json'}
+
+    for k,v in headers.items():
+        new_headers[k.capitalize()] = v
+
     try:
         async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session:
-            async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp:
+            async with session.get(uri, headers=new_headers) as resp:
                 if resp.status != 200:
                     return None
                 ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None))