[Pkg-owncloud-commits] [owncloud] 07/215: Use 403 instead a 50x response
David Prévot
taffit at moszumanska.debian.org
Tue May 5 01:01:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit ed0b465cf9c2d4f257d8f1e2fabcd443f133ca38
Author: Lukas Reschke <lukas at owncloud.com>
Date: Mon Apr 20 12:53:40 2015 +0200
Use 403 instead a 50x response
---
.../connector/sabre/blocklegacyclientplugin.php | 19 +++++++++----------
.../connector/sabre/BlockLegacyClientPluginTest.php | 3 ++-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/private/connector/sabre/blocklegacyclientplugin.php b/lib/private/connector/sabre/blocklegacyclientplugin.php
index 4d595b5..7da6ff5 100644
--- a/lib/private/connector/sabre/blocklegacyclientplugin.php
+++ b/lib/private/connector/sabre/blocklegacyclientplugin.php
@@ -21,20 +21,19 @@
namespace OC\Connector\Sabre;
-use OC\ServiceUnavailableException;
use OCP\IConfig;
use Sabre\HTTP\RequestInterface;
use Sabre\DAV\ServerPlugin;
-use Sabre\DAV\Server;
+use Sabre\DAV\Exception;
/**
* Class BlockLegacyClientPlugin is used to detect old legacy sync clients and
- * returns a 503 status to those clients.
+ * returns a 403 status to those clients
*
* @package OC\Connector\Sabre
*/
class BlockLegacyClientPlugin extends ServerPlugin {
- /** @var Server */
+ /** @var \Sabre\DAV\Server */
protected $server;
/** @var IConfig */
protected $config;
@@ -47,19 +46,19 @@ class BlockLegacyClientPlugin extends ServerPlugin {
}
/**
- * @param Server $server
+ * @param \Sabre\DAV\ $server
* @return void
*/
- public function initialize(Server $server) {
+ public function initialize(\Sabre\DAV\Server $server) {
$this->server = $server;
$this->server->on('beforeMethod', [$this, 'beforeHandler'], 200);
}
/**
- * Detects all unsupported clients and throws a ServiceUnavailableException
- * which will result in a 503 to them.
+ * Detects all unsupported clients and throws a \Sabre\DAV\Exception\Forbidden
+ * exception which will result in a 403 to them.
* @param RequestInterface $request
- * @throws ServiceUnavailableException If the client version is not supported
+ * @throws \Sabre\DAV\Exception\Forbidden If the client version is not supported
*/
public function beforeHandler(RequestInterface $request) {
$userAgent = $request->getHeader('User-Agent');
@@ -70,7 +69,7 @@ class BlockLegacyClientPlugin extends ServerPlugin {
preg_match("/(?:mirall\\/)([\d.]+)/i", $userAgent, $versionMatches);
if(isset($versionMatches[1]) &&
version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1) {
- throw new ServiceUnavailableException('Unsupported client version.');
+ throw new \Sabre\DAV\Exception\Forbidden('Unsupported client version.');
}
}
}
diff --git a/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php b/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
index ed735f0..2c7835d 100644
--- a/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
+++ b/tests/lib/connector/sabre/BlockLegacyClientPluginTest.php
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace Test\Connector\Sabre;
use OC\Connector\Sabre\BlockLegacyClientPlugin;
@@ -58,7 +59,7 @@ class BlockLegacyClientPluginTest extends TestCase {
/**
* @dataProvider oldDesktopClientProvider
* @param string $userAgent
- * @expectedException \OC\ServiceUnavailableException
+ * @expectedException \Sabre\DAV\Exception\Forbidden
* @expectedExceptionMessage Unsupported client version.
*/
public function testBeforeHandlerException($userAgent) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list