1
0

TooManyRequestsResponse.php 953 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\AppFramework\Http;
  8. use OCP\AppFramework\Http;
  9. use OCP\Template;
  10. /**
  11. * A generic 429 response showing an 404 error page as well to the end-user
  12. * @since 19.0.0
  13. * @template S of int
  14. * @template H of array<string, mixed>
  15. * @template-extends Response<int, array<string, mixed>>
  16. */
  17. class TooManyRequestsResponse extends Response {
  18. /**
  19. * @param S $status
  20. * @param H $headers
  21. * @since 19.0.0
  22. */
  23. public function __construct(int $status = Http::STATUS_TOO_MANY_REQUESTS, array $headers = []) {
  24. parent::__construct($status, $headers);
  25. $this->setContentSecurityPolicy(new ContentSecurityPolicy());
  26. }
  27. /**
  28. * @return string
  29. * @since 19.0.0
  30. */
  31. public function render() {
  32. $template = new Template('core', '429', 'blank');
  33. return $template->fetchPage();
  34. }
  35. }