aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/AppFramework/Http/TooManyRequestsResponse.php
blob: b7b0a98c9e19fab9611ffb50b72dcc57ea8d427f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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\Template;

/**
 * A generic 429 response showing an 404 error page as well to the end-user
 * @since 19.0.0
 * @template S of int
 * @template H of array<string, mixed>
 * @template-extends Response<int, 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 = new Template('core', '429', 'blank');
		return $template->fetchPage();
	}
}