diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-07-08 19:14:05 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-07-08 19:14:05 +0200 |
commit | 222a9523b518940e3011d70a78884fc24d42eb18 (patch) | |
tree | 8286016062bafdd67379ccffca590ac7e55ae554 /lib/base.php | |
parent | 48ece9f345eac0d889c10ceacd48a5cf3999f4cf (diff) | |
download | nextcloud-server-222a9523b518940e3011d70a78884fc24d42eb18.tar.gz nextcloud-server-222a9523b518940e3011d70a78884fc24d42eb18.zip |
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>
Diffstat (limited to 'lib/base.php')
-rw-r--r-- | lib/base.php | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/base.php b/lib/base.php index 814f30b5af3..26ad684a81a 100644 --- a/lib/base.php +++ b/lib/base.php @@ -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(); |