From 32e31f1dac658398309aeba8639f8e4c12d5099d Mon Sep 17 00:00:00 2001 From: Thomas Flori <thflori@gmail.com> Date: Fri, 3 Aug 2018 07:23:08 +0200 Subject: [PATCH] send multi value headers in one header row except set-cookie https://tools.ietf.org/html/rfc7230 states out the the Set-Cookie header field is a special case that can not be combined. --- src/functions.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/functions.php b/src/functions.php index 5db6a33..8c98859 100644 --- a/src/functions.php +++ b/src/functions.php @@ -11,11 +11,17 @@ if (!function_exists('sendResponse')) { $response->getReasonPhrase() ); header($http_line, true, $response->getStatusCode()); + foreach ($response->getHeaders() as $name => $values) { - foreach ($values as $value) { - header("$name: $value", false); + if (strtolower($name) !== 'set-cookie') { + header(sprintf('%s: %s', $name, implode(',', $values)), false); + } else { + foreach ($values as $value) { + header(sprintf('%s: %s', $name, $value), false); + } } } + $stream = $response->getBody(); if ($stream->isSeekable()) { $stream->rewind(); -- GitLab