Commit 4dabe605 by Vladimir Zbrailov

added use http_get_request_headers and use getHeaders method in Gii module

parent a42710ad
......@@ -36,13 +36,15 @@ class RequestPanel extends Panel
public function save()
{
if (function_exists('apache_request_headers')) {
$requestHeaders = apache_request_headers();
} elseif (function_exists('http_get_request_headers')) {
$requestHeaders = http_get_request_headers();
} else {
$requestHeaders = [];
$headers = Yii::$app->getRequest()->getHeaders();
foreach ($headers as $name => $value) {
if (is_array($value) && count($value) == 1) {
$requestHeaders[$name] = current($value);
} else {
$requestHeaders[$name] = $value;
}
}
$responseHeaders = [];
foreach (headers_list() as $header) {
if (($pos = strpos($header, ':')) !== false) {
......
......@@ -182,11 +182,11 @@ class Request extends \yii\base\Request
{
if ($this->_headers === null) {
$this->_headers = new HeaderCollection;
$headers = [];
if (function_exists('getallheaders')) {
$headers = getallheaders();
foreach ($headers as $name => $value) {
$this->_headers->add($name, $value);
}
} elseif (function_exists('http_get_request_headers')) {
$headers = http_get_request_headers();
} else {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
......@@ -194,8 +194,13 @@ class Request extends \yii\base\Request
$this->_headers->add($name, $value);
}
}
return $this->_headers;
}
foreach ($headers as $name => $value) {
$this->_headers->add($name, $value);
}
}
return $this->_headers;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment