]> git.mxchange.org Git - friendica.git/commitdiff
Make requested changes
authorGidi Kroon <Gidi@gidikroon.eu>
Sun, 25 Jun 2023 18:54:04 +0000 (20:54 +0200)
committerGidi Kroon <Gidi@gidikroon.eu>
Sun, 25 Jun 2023 18:54:04 +0000 (20:54 +0200)
src/Module/ActivityPub/Objects.php
src/Module/Friendica.php
src/Module/Item/Display.php
src/Module/Profile/Profile.php
src/Module/Xrd.php

index 2d5862a1c4aeca22b7c1703df1dfcf7e431c4ced..f93c8b95747a1561ef873fd1c8afb3ce5258017b 100644 (file)
@@ -46,6 +46,8 @@ class Objects extends BaseModule
                        throw new HTTPException\BadRequestException();
                }
 
+               header('Vary: Accept', false);
+
                if (!ActivityPub::isRequest()) {
                        DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString()));
                }
@@ -130,8 +132,6 @@ class Objects extends BaseModule
                // Relaxed CORS header for public items
                header('Access-Control-Allow-Origin: *');
 
-               header('Vary: Accept', false);
-
                System::jsonExit($data, 'application/activity+json');
        }
 }
index 739078763fd5d6e9286f85ce0d9a80c5939c8ab0..73d5f633cd327c517ff8d6d6eee2ec5f8645b858 100644 (file)
@@ -90,8 +90,6 @@ class Friendica extends BaseModule
                        $blocked = null;
                }
 
-               header('Vary: Accept', false);
-
                $hooked = '';
 
                Hook::callAll('about_hook', $hooked);
@@ -117,6 +115,8 @@ class Friendica extends BaseModule
 
        protected function rawContent(array $request = [])
        {
+               header('Vary: Accept', false);
+
                // @TODO: Replace with parameter from router
                if (DI::args()->getArgc() <= 1 || (DI::args()->getArgv()[1] !== 'json')) {
                        if (!ActivityPub::isRequest()) {
@@ -127,7 +127,6 @@ class Friendica extends BaseModule
                                $data = ActivityPub\Transmitter::getProfile(0);
                                header('Access-Control-Allow-Origin: *');
                                header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
-                               header('Vary: Accept', false);
                                System::jsonExit($data, 'application/activity+json');
                        } catch (HTTPException\NotFoundException $e) {
                                System::jsonError(404, ['error' => 'Record not found']);
index 54e55de2fc3db8fcb5a1e29bce6c708ed5c2cd6b..a0d1ecbf56d81263d3aca04b192bf4aa0357b985 100644 (file)
@@ -88,6 +88,8 @@ class Display extends BaseModule
 
        protected function content(array $request = []): string
        {
+               header('Vary: Accept', false);
+
                if (ActivityPub::isRequest()) {
                        $this->baseUrl->redirect(str_replace('display/', 'objects/', $this->args->getQueryString()));
                }
@@ -162,8 +164,6 @@ class Display extends BaseModule
 
                $output .= $this->getDisplayData($item);
 
-               header('Vary: Accept', false);
-
                return $output;
        }
 
index b8f16656ebd4ff00b276f65ca1c98df585c858c8..31ef8d05bff3f45aea713ba8b541419a348c8d15 100644 (file)
@@ -80,6 +80,8 @@ class Profile extends BaseProfile
 
        protected function rawContent(array $request = [])
        {
+               header('Vary: Accept', false);
+
                if (ActivityPub::isRequest()) {
                        $user = $this->database->selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'] ?? '', 'account_removed' => false]);
                        if ($user) {
@@ -87,7 +89,6 @@ class Profile extends BaseProfile
                                        $data = ActivityPub\Transmitter::getProfile($user['uid']);
                                        header('Access-Control-Allow-Origin: *');
                                        header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
-                                       header('Vary: Accept', false);
                                        System::jsonExit($data, 'application/activity+json');
                                } catch (HTTPException\NotFoundException $e) {
                                        System::jsonError(404, ['error' => 'Record not found']);
@@ -104,8 +105,6 @@ class Profile extends BaseProfile
                                System::jsonError(404, []);
                        }
                }
-
-               header('Vary: Accept', false);
        }
 
        protected function content(array $request = []): string
index 71a3d37a9e996e81e34710055fd60f526d1abdb2..3267e9e9a24bbeecb6daa7d92754a29687c3bf7d 100644 (file)
@@ -80,6 +80,8 @@ class Xrd extends BaseModule
                        throw new NotFoundException('Invalid host name for xrd query: ' . $host);
                }
 
+               header('Vary: Accept', false);
+
                if ($name == User::getActorName()) {
                        $owner = User::getSystemAccount();
                        if (empty($owner)) {
@@ -152,7 +154,6 @@ class Xrd extends BaseModule
                        ]
                ];
                header('Access-Control-Allow-Origin: *');
-               header('Vary: Accept', false);
                System::jsonExit($json, 'application/jrd+json; charset=utf-8');
        }
 
@@ -230,7 +231,6 @@ class Xrd extends BaseModule
                ];
 
                header('Access-Control-Allow-Origin: *');
-               header('Vary: Accept', false);
                System::jsonExit($json, 'application/jrd+json; charset=utf-8');
        }
 
@@ -328,7 +328,6 @@ class Xrd extends BaseModule
                ]);
 
                header('Access-Control-Allow-Origin: *');
-               header('Vary: Accept', false);
                System::httpExit($xmlString, Response::TYPE_XML, 'application/xrd+xml');
        }
 }