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 ...@@ -36,13 +36,15 @@ class RequestPanel extends Panel
public function save() public function save()
{ {
if (function_exists('apache_request_headers')) { $headers = Yii::$app->getRequest()->getHeaders();
$requestHeaders = apache_request_headers(); foreach ($headers as $name => $value) {
} elseif (function_exists('http_get_request_headers')) { if (is_array($value) && count($value) == 1) {
$requestHeaders = http_get_request_headers(); $requestHeaders[$name] = current($value);
} else { } else {
$requestHeaders = []; $requestHeaders[$name] = $value;
} }
}
$responseHeaders = []; $responseHeaders = [];
foreach (headers_list() as $header) { foreach (headers_list() as $header) {
if (($pos = strpos($header, ':')) !== false) { if (($pos = strpos($header, ':')) !== false) {
......
...@@ -182,11 +182,11 @@ class Request extends \yii\base\Request ...@@ -182,11 +182,11 @@ class Request extends \yii\base\Request
{ {
if ($this->_headers === null) { if ($this->_headers === null) {
$this->_headers = new HeaderCollection; $this->_headers = new HeaderCollection;
$headers = [];
if (function_exists('getallheaders')) { if (function_exists('getallheaders')) {
$headers = getallheaders(); $headers = getallheaders();
foreach ($headers as $name => $value) { } elseif (function_exists('http_get_request_headers')) {
$this->_headers->add($name, $value); $headers = http_get_request_headers();
}
} else { } else {
foreach ($_SERVER as $name => $value) { foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') { if (substr($name, 0, 5) == 'HTTP_') {
...@@ -194,8 +194,13 @@ class Request extends \yii\base\Request ...@@ -194,8 +194,13 @@ class Request extends \yii\base\Request
$this->_headers->add($name, $value); $this->_headers->add($name, $value);
} }
} }
return $this->_headers;
}
foreach ($headers as $name => $value) {
$this->_headers->add($name, $value);
} }
} }
return $this->_headers; 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