mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 06:28:40 +00:00
cache server headers
This commit is contained in:
parent
f554feae82
commit
2177024fdc
|
|
@ -37,6 +37,14 @@ final class HttpHeader extends HeaderAbstract
|
||||||
*/
|
*/
|
||||||
private array $header = [];
|
private array $header = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server headers.
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static $serverHeaders = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -138,17 +146,20 @@ final class HttpHeader extends HeaderAbstract
|
||||||
*/
|
*/
|
||||||
public static function getAllHeaders() : array
|
public static function getAllHeaders() : array
|
||||||
{
|
{
|
||||||
|
if (!empty(self::$serverHeaders)) {
|
||||||
|
return self::$serverHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
if (\function_exists('getallheaders')) {
|
if (\function_exists('getallheaders')) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
return \getallheaders();
|
self::$serverHeaders = \getallheaders();
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = [];
|
|
||||||
foreach ($_SERVER as $name => $value) {
|
foreach ($_SERVER as $name => $value) {
|
||||||
$part = \substr($name, 5);
|
$part = \substr($name, 5);
|
||||||
if ($part === 'HTTP_') {
|
if ($part === 'HTTP_') {
|
||||||
$headers[
|
self::$serverHeaders[
|
||||||
\str_replace(
|
\str_replace(
|
||||||
' ',
|
' ',
|
||||||
'-',
|
'-',
|
||||||
|
|
@ -162,7 +173,7 @@ final class HttpHeader extends HeaderAbstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $headers;
|
return self::$serverHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user