2015-05-21 11:19:07 -04:00
|
|
|
<?php
|
2026-03-26 12:46:27 -04:00
|
|
|
|
|
|
|
|
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2015-05-21 11:19:07 -04:00
|
|
|
|
|
|
|
|
namespace Icinga\Exception\Http;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Exception thrown if the HTTP method is not allowed
|
|
|
|
|
*/
|
2017-07-05 00:26:58 -04:00
|
|
|
class HttpMethodNotAllowedException extends BaseHttpException
|
2015-05-21 11:19:07 -04:00
|
|
|
{
|
2017-07-05 00:26:58 -04:00
|
|
|
protected $statusCode = 405;
|
2015-05-21 11:19:07 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the allowed HTTP methods
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getAllowedMethods()
|
|
|
|
|
{
|
2017-07-05 00:26:58 -04:00
|
|
|
$headers = $this->getHeaders();
|
|
|
|
|
return isset($headers['Allow']) ? $headers['Allow'] : null;
|
2015-05-21 11:19:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the allowed HTTP methods
|
|
|
|
|
*
|
|
|
|
|
* @param string $allowedMethods
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
|
|
|
|
public function setAllowedMethods($allowedMethods)
|
|
|
|
|
{
|
2017-07-05 00:26:58 -04:00
|
|
|
$this->setHeader('Allow', (string) $allowedMethods);
|
2015-05-21 11:19:07 -04:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
}
|