Skip to content

Commit

Permalink
Likely a dead end
Browse files Browse the repository at this point in the history
  • Loading branch information
ebln committed Jun 8, 2024
1 parent 86390d8 commit 63ba141
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Transcriptor/Response/SingleCookiePassTranscriptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace brnc\Symfony1\Message\Transcriptor\Response;

use brnc\Symfony1\Message\Exception\LogicException;
use Psr\Http\Message\ResponseInterface;

/**
* Pass-through for a single `Set-Cookie` header.
*
* Be careful! Mind encoding, multiple cookies with the same name,
* esp. conflicts with cookies already staged in Symfony1 (and sent via `setrawcookie()`)
*/
class SingleCookiePassTranscriptor implements CookieTranscriptorInterface
{
public function transcribeCookies(ResponseInterface $psrResponse, \sfWebResponse $sfWebResponse): void
{
$setCookies = $psrResponse->getHeader('Set-Cookie');
if (count($setCookies) > 1) {
LogicException::throwCookieTranscriptionUnsupported();
}
$sfWebResponse->setHttpHeader('Set-Cookie', $setCookies[0], true);
}
}

0 comments on commit 63ba141

Please sign in to comment.