Skip to content

Commit dd27fff

Browse files
author
Oleksandr Gorkun
committed
MC-19926: Implement CSP
1 parent 90f5bc5 commit dd27fff

File tree

1 file changed

+10
-1
lines changed
  • lib/internal/Magento/Framework/HTTP/PhpEnvironment

1 file changed

+10
-1
lines changed

lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Framework\HTTP\PhpEnvironment;
77

8+
use Zend\Http\Header\GenericMultiHeader;
9+
810
/**
911
* Base HTTP response object
1012
*/
@@ -77,11 +79,18 @@ public function setHeader($name, $value, $replace = false)
7779
{
7880
$value = (string)$value;
7981

82+
$headers = $this->getHeaders();
8083
if ($replace) {
84+
$headers->addHeaderLine($name, $value);
8185
$this->clearHeader($name);
86+
} else {
87+
//Zend framework will only force multiple headers for header objects
88+
//extending MultiHeader interface.
89+
$pluginKey = str_replace('-', '', mb_strtolower($name));
90+
$headers->getPluginClassLoader()->registerPlugin($pluginKey, GenericMultiHeader::class);
91+
$headers->addHeader(new GenericMultiHeader($name, $value));
8292
}
8393

84-
$this->getHeaders()->addHeaderLine($name, $value);
8594
return $this;
8695
}
8796

0 commit comments

Comments
 (0)