0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-03 21:40:31 +00:00
nextcloud_server/lib/public/AppFramework/Http/TooManyRequestsResponse.php
Côme Chilliet 253628ad5a fix: Fix psalm issues and add missing methods to ITemplate interface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-06 15:49:25 +01:00

41 lines
1 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\AppFramework\Http;
use OCP\AppFramework\Http;
use OCP\Server;
use OCP\Template\ITemplateManager;
/**
* A generic 429 response showing an 404 error page as well to the end-user
* @since 19.0.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class TooManyRequestsResponse extends Response {
/**
* @param S $status
* @param H $headers
* @since 19.0.0
*/
public function __construct(int $status = Http::STATUS_TOO_MANY_REQUESTS, array $headers = []) {
parent::__construct($status, $headers);
$this->setContentSecurityPolicy(new ContentSecurityPolicy());
}
/**
* @return string
* @since 19.0.0
*/
public function render() {
$template = Server::get(ITemplateManager::class)->getTemplate('core', '429', TemplateResponse::RENDER_AS_BLANK);
return $template->fetchPage();
}
}