diff --git a/src/Module/ActivityPub/Objects.php b/src/Module/ActivityPub/Objects.php index 2d5862a1c..f93c8b957 100644 --- a/src/Module/ActivityPub/Objects.php +++ b/src/Module/ActivityPub/Objects.php @@ -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'); } } diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index 739078763..73d5f633c 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -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']); diff --git a/src/Module/Item/Display.php b/src/Module/Item/Display.php index 54e55de2f..a0d1ecbf5 100644 --- a/src/Module/Item/Display.php +++ b/src/Module/Item/Display.php @@ -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; } diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index b8f16656e..31ef8d05b 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -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 diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 71a3d37a9..3267e9e9a 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -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'); } }