Skip to content

Commit

Permalink
bug symfony#61 removed 'Set-Cookie' from header when it is already co…
Browse files Browse the repository at this point in the history
…nverted to a Symfony header cookie (tinyroy)

This PR was merged into the 1.2-dev branch.

Discussion
----------

removed 'Set-Cookie' from header when it is already converted to a Symfony header cookie

Fix #25
Fix #26

Commits
-------

dd1111e removed 'Set-Cookie' from header when it is already converted to a Symfony header cookie
  • Loading branch information
nicolas-grekas committed Mar 11, 2019
2 parents ba672d8 + dd1111e commit 8592ca3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Factory/HttpFoundationFactory.php
Expand Up @@ -140,14 +140,17 @@ protected function getTemporaryPath()
*/
public function createResponse(ResponseInterface $psrResponse)
{
$cookies = $psrResponse->getHeader('Set-Cookie');
$psrResponse = $psrResponse->withHeader('Set-Cookie', array());

$response = new Response(
$psrResponse->getBody()->__toString(),
$psrResponse->getStatusCode(),
$psrResponse->getHeaders()
);
$response->setProtocolVersion($psrResponse->getProtocolVersion());

foreach ($psrResponse->getHeader('Set-Cookie') as $cookie) {
foreach ($cookies as $cookie) {
$response->headers->setCookie($this->createCookie($cookie));
}

Expand Down
4 changes: 3 additions & 1 deletion Tests/Fixtures/Message.php
Expand Up @@ -64,7 +64,9 @@ public function getHeaderLine($name)

public function withHeader($name, $value)
{
throw new \BadMethodCallException('Not implemented.');
$this->headers[$name] = (array) $value;

return $this;
}

public function withAddedHeader($name, $value)
Expand Down

0 comments on commit 8592ca3

Please sign in to comment.