MethodNotAllowed.php 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAV\Exception;
  4. use Sabre\DAV;
  5. use Sabre\DAV\Server;
  6. /**
  7. * MethodNotAllowed.
  8. *
  9. * The 405 is thrown when a client tried to create a directory on an already existing directory
  10. *
  11. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  12. * @author Evert Pot (http://evertpot.com/)
  13. * @license http://sabre.io/license/ Modified BSD License
  14. */
  15. class MethodNotAllowed extends DAV\Exception
  16. {
  17. /**
  18. * Returns the HTTP statuscode for this exception.
  19. *
  20. * @return int
  21. */
  22. public function getHTTPCode()
  23. {
  24. return 405;
  25. }
  26. /**
  27. * This method allows the exception to return any extra HTTP response headers.
  28. *
  29. * The headers must be returned as an array.
  30. *
  31. * @return array
  32. */
  33. public function getHTTPHeaders(Server $server)
  34. {
  35. $methods = $server->getAllowedMethods($server->getRequestUri());
  36. return [
  37. 'Allow' => strtoupper(implode(', ', $methods)),
  38. ];
  39. }
  40. }