diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index 3be8214d42b4..372f23bc6d89 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -236,7 +236,12 @@ protected function parseOptions(array $options) if (array_key_exists('headers', $options) && is_array($options['headers'])) { foreach ($options['headers'] as $name => $value) { - $this->setHeader($name, $value); + // fix issue #5041 by taking into account multiple headers with the same name + if($this->hasHeader($name)) { + $this->appendHeader($name, $value); + } else { + $this->setHeader($name, $value); + } } unset($options['headers']); diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index 2b1205a5d47a..766363a27613 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -468,7 +468,15 @@ public function sendHeaders() // Send all of our headers foreach (array_keys($this->getHeaders()) as $name) { - header($name . ': ' . $this->getHeaderLine($name), false, $this->getStatusCode()); + // fix issue #5041 by taking into account multiple headers with the same name + $headerValue = $this->getHeader($name)->getValue(); + if(is_array($headerValue)) { + foreach($headerValue as $h_value) { + header($name . ': ' . $h_value, false, $this->getStatusCode()); + } + } else { + header($name . ': ' . $this->getHeaderLine($name), false, $this->getStatusCode()); + } } return $this;