From: Bernhard Posselt Date: Sun, 20 Apr 2014 14:12:46 +0000 (+0200) Subject: make download and redirectresponse public X-Git-Tag: v7.0.0alpha2~392^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7e447f4f42de8dc0cf9a1f92c61a71dfda8f8dcd;p=nextcloud-server.git make download and redirectresponse public --- diff --git a/lib/private/appframework/http/downloadresponse.php b/lib/private/appframework/http/downloadresponse.php deleted file mode 100644 index 67b9542dba6..00000000000 --- a/lib/private/appframework/http/downloadresponse.php +++ /dev/null @@ -1,50 +0,0 @@ -. - * - */ - - -namespace OC\AppFramework\Http; - - -/** - * Prompts the user to download the a file - */ -class DownloadResponse extends \OCP\AppFramework\Http\Response { - - private $filename; - private $contentType; - - /** - * Creates a response that prompts the user to download the file - * @param string $filename the name that the downloaded file should have - * @param string $contentType the mimetype that the downloaded file should have - */ - public function __construct($filename, $contentType) { - $this->filename = $filename; - $this->contentType = $contentType; - - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); - $this->addHeader('Content-Type', $contentType); - } - - -} diff --git a/lib/private/appframework/http/redirectresponse.php b/lib/private/appframework/http/redirectresponse.php deleted file mode 100644 index 05353349065..00000000000 --- a/lib/private/appframework/http/redirectresponse.php +++ /dev/null @@ -1,57 +0,0 @@ -. - * - */ - - -namespace OC\AppFramework\Http; - -use OCP\AppFramework\Http\Response; -use OCP\AppFramework\Http; - - -/** - * Redirects to a different URL - */ -class RedirectResponse extends Response { - - private $redirectURL; - - /** - * Creates a response that redirects to a url - * @param string $redirectURL the url to redirect to - */ - public function __construct($redirectURL) { - $this->redirectURL = $redirectURL; - $this->setStatus(Http::STATUS_TEMPORARY_REDIRECT); - $this->addHeader('Location', $redirectURL); - } - - - /** - * @return string the url to redirect - */ - public function getRedirectURL() { - return $this->redirectURL; - } - - -} diff --git a/lib/private/appframework/middleware/security/securitymiddleware.php b/lib/private/appframework/middleware/security/securitymiddleware.php index bb02d565fa4..0f160d224ad 100644 --- a/lib/private/appframework/middleware/security/securitymiddleware.php +++ b/lib/private/appframework/middleware/security/securitymiddleware.php @@ -25,8 +25,8 @@ namespace OC\AppFramework\Middleware\Security; use OC\AppFramework\Http; -use OC\AppFramework\Http\RedirectResponse; use OC\AppFramework\Utility\MethodAnnotationReader; +use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Middleware; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\JSONResponse; diff --git a/lib/public/appframework/http/downloadresponse.php b/lib/public/appframework/http/downloadresponse.php new file mode 100644 index 00000000000..d3c2818e828 --- /dev/null +++ b/lib/public/appframework/http/downloadresponse.php @@ -0,0 +1,50 @@ +. + * + */ + + +namespace OCP\AppFramework\Http; + + +/** + * Prompts the user to download the a file + */ +class DownloadResponse extends \OCP\AppFramework\Http\Response { + + private $filename; + private $contentType; + + /** + * Creates a response that prompts the user to download the file + * @param string $filename the name that the downloaded file should have + * @param string $contentType the mimetype that the downloaded file should have + */ + public function __construct($filename, $contentType) { + $this->filename = $filename; + $this->contentType = $contentType; + + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $this->addHeader('Content-Type', $contentType); + } + + +} diff --git a/lib/public/appframework/http/redirectresponse.php b/lib/public/appframework/http/redirectresponse.php new file mode 100644 index 00000000000..416e1533635 --- /dev/null +++ b/lib/public/appframework/http/redirectresponse.php @@ -0,0 +1,57 @@ +. + * + */ + + +namespace OCP\AppFramework\Http; + +use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http; + + +/** + * Redirects to a different URL + */ +class RedirectResponse extends Response { + + private $redirectURL; + + /** + * Creates a response that redirects to a url + * @param string $redirectURL the url to redirect to + */ + public function __construct($redirectURL) { + $this->redirectURL = $redirectURL; + $this->setStatus(Http::STATUS_TEMPORARY_REDIRECT); + $this->addHeader('Location', $redirectURL); + } + + + /** + * @return string the url to redirect + */ + public function getRedirectURL() { + return $this->redirectURL; + } + + +} diff --git a/tests/lib/appframework/http/DownloadResponseTest.php b/tests/lib/appframework/http/DownloadResponseTest.php index 64fe7992b6a..b305c63ad4d 100644 --- a/tests/lib/appframework/http/DownloadResponseTest.php +++ b/tests/lib/appframework/http/DownloadResponseTest.php @@ -22,7 +22,7 @@ */ -namespace OC\AppFramework\Http; +namespace OCP\AppFramework\Http; //require_once(__DIR__ . "/../classloader.php"); diff --git a/tests/lib/appframework/http/RedirectResponseTest.php b/tests/lib/appframework/http/RedirectResponseTest.php index f82d0c3a675..f62b420f4ee 100644 --- a/tests/lib/appframework/http/RedirectResponseTest.php +++ b/tests/lib/appframework/http/RedirectResponseTest.php @@ -22,7 +22,7 @@ */ -namespace OC\AppFramework\Http; +namespace OCP\AppFramework\Http; use OCP\AppFramework\Http; diff --git a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php index 63c48a62829..19e8a68c388 100644 --- a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php +++ b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php @@ -26,7 +26,7 @@ namespace OC\AppFramework\Middleware\Security; use OC\AppFramework\Http; use OC\AppFramework\Http\Request; -use OC\AppFramework\Http\RedirectResponse; +use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\JSONResponse;