diff --git a/framework/http/HeaderCollection.php b/framework/http/HeaderCollection.php index 24fa572..a9c9d80 100644 --- a/framework/http/HeaderCollection.php +++ b/framework/http/HeaderCollection.php @@ -183,8 +183,12 @@ class HeaderCollection extends BaseObject implements \IteratorAggregate, \ArrayA { $this->removeAll(); foreach ($array as $name => $values) { - foreach ($values as $value) { - $this->add($name, $value); + if (is_array($values)) { + foreach ($values as $value) { + $this->add($name, $value); + } + } else { + $this->add($name, $values); } } } diff --git a/framework/web/Request.php b/framework/web/Request.php index 416540b..e4a193b 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -236,10 +236,6 @@ class Request extends \yii\base\Request implements RequestInterface } } - foreach ($headers as $name => $value) { - $headers[strtolower($name)] = (array)$value; - } - return $headers; } diff --git a/tests/framework/filters/HostControlTest.php b/tests/framework/filters/HostControlTest.php index 0cb1bc8..2da4104 100644 --- a/tests/framework/filters/HostControlTest.php +++ b/tests/framework/filters/HostControlTest.php @@ -91,7 +91,7 @@ class HostControlTest extends TestCase */ public function testFilter($allowedHosts, $host, $allowed) { - $_SERVER['HTTP_HOST'] = $host; + Yii::$app->request->setHeader('Host', $host); $filter = new HostControl(); $filter->allowedHosts = $allowedHosts;