*/
public function __construct($data='', $statusCode=Http::STATUS_OK,
$headers=[]) {
+ parent::__construct();
+
$this->data = $data;
$this->setStatus($statusCode);
$this->setHeaders(array_merge($this->getHeaders(), $headers));
*/
public function __construct($data=array(), $statusCode=Http::STATUS_OK,
array $headers=array()) {
+ parent::__construct();
+
$this->data = $data;
$this->setStatus($statusCode);
$this->setHeaders(array_merge($this->getHeaders(), $headers));
* Prompts the user to download the a file
* @since 7.0.0
*/
-class DownloadResponse extends \OCP\AppFramework\Http\Response {
+class DownloadResponse extends Response {
private $filename;
private $contentType;
* @since 7.0.0
*/
public function __construct($filename, $contentType) {
+ parent::__construct();
+
$this->filename = $filename;
$this->contentType = $contentType;
*/
public function __construct($file, $statusCode=Http::STATUS_OK,
$headers=[]) {
+ parent::__construct();
+
$this->file = $file;
$this->setStatus($statusCode);
$this->setHeaders(array_merge($this->getHeaders(), $headers));
* @since 6.0.0
*/
public function __construct($data=array(), $statusCode=Http::STATUS_OK) {
+ parent::__construct();
+
$this->data = $data;
$this->setStatus($statusCode);
$this->addHeader('Content-Type', 'application/json; charset=utf-8');
* @since 8.1.0
*/
public function __construct() {
+ parent::__construct();
+
$this->setStatus(404);
}
public function __construct($format, $statuscode, $message,
$data=[], $itemscount='',
$itemsperpage='') {
+ parent::__construct();
+
$this->format = $format;
$this->statuscode = $statuscode;
$this->message = $message;
* @since 7.0.0
*/
public function __construct($redirectURL) {
+ parent::__construct();
+
$this->redirectURL = $redirectURL;
$this->setStatus(Http::STATUS_SEE_OTHER);
$this->addHeader('Location', $redirectURL);
/** @var array */
private $throttleMetadata = [];
+ /**
+ * Response constructor.
+ *
+ * @since 17.0.0
+ */
+ public function __construct() {
+ $this->setContentSecurityPolicy(new EmptyContentSecurityPolicy());
+ }
+
/**
* Caches the response
* @param int $cacheSeconds the amount of seconds that should be cached
* @since 8.1.0
*/
public function __construct ($filePath) {
+ parent::__construct();
+
$this->filePath = $filePath;
}
*/
public function __construct($appName, $templateName, array $params=array(),
$renderAs='user') {
+ parent::__construct();
+
$this->templateName = $templateName;
$this->appName = $appName;
$this->params = $params;
$this->renderAs = $renderAs;
+
+ $this->setContentSecurityPolicy(new ContentSecurityPolicy());
}
* @since 15.0.0
*/
public function __construct(IRequest $request, string $name = 'output') {
+ parent::__construct();
+
$this->name = $name;
$this->request = $request;
}
'test' => 'something',
'Cache-Control' => 'no-cache, no-store, must-revalidate',
'Content-Type' => 'application/json; charset=utf-8',
- 'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self'",
+ 'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
];
$response = $this->controller->customDataResponse(array('hi'));
$expectedHeaders = [
'Cache-Control' => 'no-cache, no-store, must-revalidate',
- 'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self'",
+ 'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
];
$expectedHeaders = array_merge($expectedHeaders, $headers);
$this->childResponse->setHeaders($expected);
$headers = $this->childResponse->getHeaders();
- $expected['Content-Security-Policy'] = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self'";
+ $expected['Content-Security-Policy'] = "default-src 'none';base-uri 'none';manifest-src 'self'";
$this->assertEquals($expected, $headers);
}
}
public function testGetCspEmpty() {
- $this->assertNull($this->childResponse->getContentSecurityPolicy());
+ $this->assertEquals(new Http\EmptyContentSecurityPolicy(), $this->childResponse->getContentSecurityPolicy());
}
public function testAddHeaderValueNullDeletesIt(){