Skip to content

Commit

Permalink
Merge pull request #2789 from mapogolions/fix/header-field-case-insen…
Browse files Browse the repository at this point in the history
…sitive

Cookie-header detection must be case insensitive
  • Loading branch information
l0gicgate authored Aug 10, 2019
2 parents 4ddb1bf + c6b9b5f commit 240536f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Slim/ResponseEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function emit(ResponseInterface $response): void
private function emitHeaders(ResponseInterface $response): void
{
foreach ($response->getHeaders() as $name => $values) {
$first = $name !== 'Set-Cookie';
$first = strtolower($name) !== 'set-cookie';
foreach ($values as $value) {
$header = sprintf('%s: %s', $name, $value);
header($header, $first);
Expand Down
8 changes: 4 additions & 4 deletions tests/ResponseEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ public function testResponseDoesNotReplacePreviouslySetSetCookieHeaders()
{
$response = $this
->createResponse(200, 'OK')
->withHeader('Set-Cookie', 'foo=bar')
->withHeader('set-cOOkie', 'foo=bar')
->withAddedHeader('Set-Cookie', 'bar=baz');
$responseEmitter = new ResponseEmitter();
$responseEmitter->emit($response);

$expectedStack = [
['header' => 'Set-Cookie: foo=bar', 'replace' => false, 'status_code' => null],
['header' => 'Set-Cookie: bar=baz', 'replace' => false, 'status_code' => null],
['header' => 'set-cOOkie: foo=bar', 'replace' => false, 'status_code' => null],
['header' => 'set-cOOkie: bar=baz', 'replace' => false, 'status_code' => null],
['header' => 'HTTP/1.1 200 OK', 'replace' => true, 'status_code' => 200],
];

Expand All @@ -179,7 +179,7 @@ public function testAvoidReadFromSlowStreamAccordingStatus()
$response = $this
->createResponse(204, 'No content')
->withBody($body);

$responseEmitter = new ResponseEmitter();
$responseEmitter->emit($response);

Expand Down

0 comments on commit 240536f

Please sign in to comment.