diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-08-19 15:53:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-19 15:53:03 +0200 |
commit | 1521da14ff292cb257f442a5f16c41b29faec337 (patch) | |
tree | 0c61e6db0e2bd85835e23bfd051c4a68308a5f6f | |
parent | 1e69a691e10e36447fa66adb16dcc05e35237f69 (diff) | |
parent | c40fe8b819053c327394996c165254b6d19bfeab (diff) | |
download | nextcloud-server-1521da14ff292cb257f442a5f16c41b29faec337.tar.gz nextcloud-server-1521da14ff292cb257f442a5f16c41b29faec337.zip |
Merge pull request #16788 from nextcloud/enh/no_response_constructor
Do not enforce the parent constructor of response to be called
-rw-r--r-- | lib/public/AppFramework/Http/Response.php | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index bfee7d51549..f46aa9e2880 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -93,13 +93,9 @@ class Response { private $throttleMetadata = []; /** - * Response constructor. - * * @since 17.0.0 */ public function __construct() { - $this->setContentSecurityPolicy(new EmptyContentSecurityPolicy()); - $this->setFeaturePolicy(new EmptyFeaturePolicy()); } /** @@ -241,12 +237,8 @@ class Response { $this->lastModified->format(\DateTime::RFC2822); } - // Build Content-Security-Policy and use default if none has been specified - if(is_null($this->contentSecurityPolicy)) { - $this->setContentSecurityPolicy(new ContentSecurityPolicy()); - } - $this->headers['Content-Security-Policy'] = $this->contentSecurityPolicy->buildPolicy(); - $this->headers['Feature-Policy'] = $this->featurePolicy->buildPolicy(); + $this->headers['Content-Security-Policy'] = $this->getContentSecurityPolicy()->buildPolicy(); + $this->headers['Feature-Policy'] = $this->getFeaturePolicy()->buildPolicy(); if($this->ETag) { $mergeWith['ETag'] = '"' . $this->ETag . '"'; @@ -296,6 +288,9 @@ class Response { * @since 8.1.0 */ public function getContentSecurityPolicy() { + if ($this->contentSecurityPolicy === null) { + $this->setContentSecurityPolicy(new EmptyContentSecurityPolicy()); + } return $this->contentSecurityPolicy; } @@ -304,6 +299,9 @@ class Response { * @since 17.0.0 */ public function getFeaturePolicy(): EmptyFeaturePolicy { + if ($this->featurePolicy === null) { + $this->setFeaturePolicy(new EmptyFeaturePolicy()); + } return $this->featurePolicy; } |