diff libervia/backend/plugins/plugin_comp_ap_gateway/http_server.py @ 4109:7067b0d73183

component AP gateway: fix AP media type in GET and POST requests headers
author Goffi <goffi@goffi.org>
date Thu, 06 Jul 2023 11:34:52 +0200
parents 58bbc100f13b
children 5f2d496c633f
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_comp_ap_gateway/http_server.py	Thu Jul 06 11:34:51 2023 +0200
+++ b/libervia/backend/plugins/plugin_comp_ap_gateway/http_server.py	Thu Jul 06 11:34:52 2023 +0200
@@ -41,10 +41,11 @@
 from libervia.backend.memory.sqla_mapping import SubscriptionState
 
 from .constants import (
-    NS_AP, MEDIA_TYPE_AP, CONTENT_TYPE_WEBFINGER, CONTENT_TYPE_AP, TYPE_ACTOR, TYPE_INBOX,
-    TYPE_SHARED_INBOX, TYPE_OUTBOX, TYPE_EVENT, AP_REQUEST_TYPES, PAGE_SIZE,
-    ACTIVITY_TYPES_LOWER, ACTIVIY_NO_ACCOUNT_ALLOWED, SIGN_HEADERS, HS2019, SIGN_EXP,
-    TYPE_FOLLOWERS, TYPE_FOLLOWING, TYPE_ITEM, TYPE_LIKE, TYPE_REACTION, ST_AP_CACHE
+    NS_AP, MEDIA_TYPE_AP, MEDIA_TYPE_AP_ALT, CONTENT_TYPE_WEBFINGER, CONTENT_TYPE_AP,
+    TYPE_ACTOR, TYPE_INBOX, TYPE_SHARED_INBOX, TYPE_OUTBOX, TYPE_EVENT, AP_REQUEST_TYPES,
+    PAGE_SIZE, ACTIVITY_TYPES_LOWER, ACTIVIY_NO_ACCOUNT_ALLOWED, SIGN_HEADERS, HS2019,
+    SIGN_EXP, TYPE_FOLLOWERS, TYPE_FOLLOWING, TYPE_ITEM, TYPE_LIKE, TYPE_REACTION,
+    ST_AP_CACHE
 )
 from .regex import RE_SIG_PARAM
 
@@ -968,7 +969,9 @@
             path
         )
         request_type, extra_args = self.apg.parse_apurl(ap_url)
-        if ((MEDIA_TYPE_AP not in (request.getHeader("accept") or "")
+        header_accept = request.getHeader("accept") or ""
+        if ((MEDIA_TYPE_AP not in header_accept
+             and MEDIA_TYPE_AP_ALT not in header_accept
              and request_type in self.apg.html_redirect)):
             # this is not a AP request, and we have a redirections for it
             kw = {}