Fix 404 handling of requested JSON/XML

If front-end or an application requests JSON/XML, there is no point in
redirecting to the default page if that response doesn't exist. In the
worst case that would just cause another request, therefore server load,
traffic and a response that is meaningless to the requester.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2022-07-08 19:14:05 +02:00
parent 48ece9f345
commit 222a9523b5
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 7 additions and 0 deletions

View File

@ -1048,6 +1048,13 @@ class OC {
return;
}
// Handle requests for JSON or XML
$acceptHeader = $request->getHeader('Accept');
if (in_array($acceptHeader, ['application/json', 'application/xml'], true)) {
http_response_code(404);
return;
}
// Someone is logged in
if (\OC::$server->getUserSession()->isLoggedIn()) {
OC_App::loadApps();