Merge pull request #13233 from GidiKroon/feature/add-vary-header

Add Vary header in case of content negotiation
This commit is contained in:
Hypolite Petovan 2023-06-25 17:56:19 -04:00 committed by GitHub
commit 7edaeb215d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 1 deletions

View 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()));
}

View file

@ -115,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()) {

View 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()));
}

View 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) {

View 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)) {
@ -326,7 +328,6 @@ class Xrd extends BaseModule
]);
header('Access-Control-Allow-Origin: *');
System::httpExit($xmlString, Response::TYPE_XML, 'application/xrd+xml');
}
}