Skip to content

Commit

Permalink
Exclude cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
timkelty committed Nov 12, 2023
1 parent 9cf9de7 commit d8ebad6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/web/ResponseBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function events(): array

public function afterPrepare(Event $event): void
{
// API Gateway v2 does not support multi-header values
$this->joinMultiValueHeaders();

if ($this->owner->stream) {
Expand Down Expand Up @@ -79,9 +78,18 @@ protected function serveBinaryFromS3(): void
$this->owner->redirect($url);
}

/**
* API Gateway v2 doesn't support multi-value headers,
* and Bref currently will truncate all but the last value.
*
* @see https://github.com/brefphp/bref/issues/1691
* @see https://developers.cloudflare.com/workers/runtime-apis/headers/#differences
* @see https://github.com/brefphp/bref/issues/1691
*/
protected function joinMultiValueHeaders(string $glue = ','): void
{
Collection::make($this->owner->getHeaders())
->reject(fn(array $values, string $name) => strcasecmp($name, 'Set-Cookie') === 0)
->each(function(array $values, string $name) use ($glue) {
$this->joinHeaderValues($name, $values, $glue);
});
Expand Down

0 comments on commit d8ebad6

Please sign in to comment.