]> git.mxchange.org Git - friendica.git/commitdiff
Issue 10947: Send correct accept-header for AP
authorMichael <heluecht@pirati.ca>
Wed, 3 Nov 2021 19:06:07 +0000 (19:06 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 3 Nov 2021 19:06:07 +0000 (19:06 +0000)
src/Protocol/ActivityPub.php
src/Protocol/ActivityPub/Receiver.php
src/Util/HTTPSignature.php

index a34854152254862a50235760e55f76fe329ffb3f..c4e88b31436550d4ef31d0a18ff522bcd252c3c7 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Protocol;
 
+use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Model\APContact;
 use Friendica\Model\User;
@@ -80,9 +81,15 @@ class ActivityPub
         */
        public static function isRequest()
        {
-               return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
+               $isrequest = stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
                        stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/json') ||
                        stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
+
+               if ($isrequest) {
+                       Logger::debug('Is AP request', ['accept' => $_SERVER['HTTP_ACCEPT'], 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
+               }
+
+               return $isrequest;
        }
 
        /**
index 431b6739ff0382d917e9cdde5d38c453f0ff3d58..34c5098709f4e48394d4e540a69d955a1726f522 100644 (file)
@@ -68,17 +68,6 @@ class Receiver
        const TARGET_ANSWER = 6;
        const TARGET_GLOBAL = 7;
 
-       /**
-        * Checks if the web request is done for the AP protocol
-        *
-        * @return bool is it AP?
-        */
-       public static function isRequest()
-       {
-               return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
-                       stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
-       }
-
        /**
         * Checks incoming message from the inbox
         *
index 58af224243e5384373e9840717ba796cf4ca5ecb..f7ede9225a8bbee75e4a939129d1d24c9918d507 100644 (file)
@@ -417,7 +417,7 @@ class HTTPSignature
         * @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function fetchRaw($request, $uid = 0, $opts = ['accept_content' => ['application/activity+json', 'application/ld+json']])
+       public static function fetchRaw($request, $uid = 0, $opts = ['accept_content' => ['application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"']])
        {
                $header = [];