Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 850bd5a

Browse files
Bart van den Burgfabpot
Bart van den Burg
authored andcommitted
[HttpFoundation] Fixed messed up headers
1 parent b9d3d07 commit 850bd5a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public function __toString()
6767
$cookies .= 'Set-Cookie: '.$cookie."\r\n";
6868
}
6969

70+
ksort($this->headerNames);
71+
7072
return parent::__toString().$cookies;
7173
}
7274

src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ public function testMakeDisposition($disposition, $filename, $filenameFallback,
235235
$this->assertEquals($expected, $headers->makeDisposition($disposition, $filename, $filenameFallback));
236236
}
237237

238+
public function testToStringDoesntMessUpHeaders()
239+
{
240+
$headers = new ResponseHeaderBag();
241+
242+
$headers->set('Location', 'http://www.symfony.com');
243+
$headers->set('Content-type', 'text/html');
244+
245+
(string) $headers;
246+
247+
$allHeaders = $headers->allPreserveCase();
248+
$this->assertEquals(array('http://www.symfony.com'), $allHeaders['Location']);
249+
$this->assertEquals(array('text/html'), $allHeaders['Content-type']);
250+
}
251+
238252
public function provideMakeDisposition()
239253
{
240254
return array(

0 commit comments

Comments
 (0)