mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 14:08:40 +00:00
Fixes #4
This commit is contained in:
parent
1914939094
commit
a03d724bbc
|
|
@ -101,6 +101,31 @@ class Response extends ResponseAbstract implements RenderableInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate header automatically based on code.
|
||||||
|
*
|
||||||
|
* @param \int $code HTTP status code
|
||||||
|
*
|
||||||
|
* @return \bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function generateHeader(\int $code)
|
||||||
|
{
|
||||||
|
if ($code === 403) {
|
||||||
|
$this->setHeader('HTTP', 'HTTP/1.0 403 Forbidden');
|
||||||
|
$this->setHeader('Status', 'Status: HTTP/1.0 403 Forbidden');
|
||||||
|
} elseif ($code === 406) {
|
||||||
|
$this->setHeader('HTTP', 'HTTP/1.0 406 Not acceptable');
|
||||||
|
$this->setHeader('Status', 'Status:406 Not acceptable');
|
||||||
|
} elseif ($code === 503) {
|
||||||
|
$this->setHeader('HTTP', 'HTTP/1.0 503 Service Temporarily Unavailable');
|
||||||
|
$this->setHeader('Status', 'Status: 503 Service Temporarily Unavailable');
|
||||||
|
$this->setHeader('Retry-After', 'Retry-After: 300');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set response.
|
* Set response.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ abstract class ResponseAbstract implements ResponseInterface, ArrayableInterface
|
||||||
public function setStatusCode(\string $status)
|
public function setStatusCode(\string $status)
|
||||||
{
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
|
$this->generateHeader($status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user