diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 866106ae6bb7..5d535c5d0c63 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -239,13 +239,10 @@ public function __construct($config) // Also ensures that a Cache-control header exists. $this->noCache(); - // Are we enforcing a Content Security Policy? - if ($config->CSPEnabled === true) - { - $this->CSP = new ContentSecurityPolicy(new \Config\ContentSecurityPolicy()); - $this->CSPEnabled = true; - } + // We need CSP object even if not enabled to avoid calls to non existing methods + $this->CSP = new ContentSecurityPolicy(new \Config\ContentSecurityPolicy()); + $this->CSPEnabled = $config->CSPEnabled; $this->cookiePrefix = $config->cookiePrefix; $this->cookieDomain = $config->cookieDomain; $this->cookiePath = $config->cookiePath;