diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 9cb68cc57608..37e6c610c25c 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -991,10 +991,9 @@ public function getVary() return array(); } - $ret = array(); foreach ($vary as $item) { - $ret = array_merge($ret, preg_split('/[\s,]+/', $item)); + $ret = array_merge($ret, preg_split('/[\s,]+/', $item)); } return $ret; diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 051975fe2c13..b9a2b9376f77 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -285,15 +285,15 @@ public function testGetVary() $response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo'); $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas'); + $vary = array('Accept-Language', 'User-Agent', 'X-foo'); + $response = new Response(); - $vary = array( - 'Accept-Language', - 'User-Agent', - 'X-foo', - ); $response->headers->set('Vary', $vary); - $this->assertEquals($response->headers->get('Vary', NULL, FALSE) , $response->getVary(), '->getVary() parses multiple header name values in arrays'); + $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); + $response = new Response(); + $response->headers->set('Vary', 'Accept-Language, User-Agent, X-foo'); + $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); } public function testSetVary() @@ -306,9 +306,7 @@ public function testSetVary() $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default'); $response->setVary('X-Foo', false); - $this->assertTrue(in_array('Accept-Language', $response->getVary()), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false'); - $this->assertTrue(in_array('User-Agent', $response->getVary()), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false'); - $this->assertTrue(in_array('X-Foo', $response->getVary()), '->setVary() adds new Vary headers when replace is set to false'); + $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false'); } public function testDefaultContentType()