/** * Merge headers from HTTP context * @param Context $context * @return array */ protected function mergeContextHeaders($context) { $headers = $this->headers->asArray(); if ($context === null) { return $headers; } $cookieUpdates = $context->cookies()->updates(); if (empty($cookieUpdates)) { return $headers; } $cookieHeaders = array(); foreach ($cookieUpdates as $update) { $cookieHeaders[] = $update->asHeader(); } foreach ($headers as $name => $value) { if (strtolower($name) === 'set-cookie') { foreach ($cookieHeaders as $header) { $headers[$name][] = $header; } return $headers; } } $headers['Set-Cookie'] = $cookieHeaders; return $headers; }