2015-02-18 15:41:42 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Christoph Wickert <cwickert@suse.de>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-03-26 13:44:34 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-26 13:44:34 +03:00
|
|
|
*
|
2015-02-18 15:41:42 +03:00
|
|
|
*/
|
|
|
|
|
2015-08-30 20:13:01 +03:00
|
|
|
namespace OCA\DAV\Connector\Sabre;
|
2020-04-09 12:48:10 +03:00
|
|
|
|
2015-05-15 10:07:39 +03:00
|
|
|
use Sabre\HTTP\RequestInterface;
|
2019-11-22 22:52:10 +03:00
|
|
|
use Sabre\HTTP\ResponseInterface;
|
2015-02-18 15:41:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class DummyGetResponsePlugin is a plugin used to not show a "Not implemented"
|
2017-04-12 07:16:27 +03:00
|
|
|
* error to clients that rely on verifying the functionality of the Nextcloud
|
2015-02-18 15:41:42 +03:00
|
|
|
* WebDAV backend using a simple GET to /.
|
|
|
|
*
|
|
|
|
* This is considered a legacy behaviour and implementers should consider sending
|
|
|
|
* a PROPFIND request instead to verify whether the WebDAV component is working
|
|
|
|
* properly.
|
|
|
|
*
|
|
|
|
* FIXME: Remove once clients are all compliant.
|
|
|
|
*
|
2015-08-30 20:13:01 +03:00
|
|
|
* @package OCA\DAV\Connector\Sabre
|
2015-02-18 15:41:42 +03:00
|
|
|
*/
|
|
|
|
class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
|
|
|
|
/** @var \Sabre\DAV\Server */
|
|
|
|
protected $server;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \Sabre\DAV\Server $server
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-05-15 10:07:39 +03:00
|
|
|
function initialize(\Sabre\DAV\Server $server) {
|
2015-02-18 15:41:42 +03:00
|
|
|
$this->server = $server;
|
2015-05-15 10:07:39 +03:00
|
|
|
$this->server->on('method:GET', [$this, 'httpGet'], 200);
|
2015-02-18 15:41:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-15 10:07:39 +03:00
|
|
|
* @param RequestInterface $request
|
|
|
|
* @param ResponseInterface $response
|
2015-02-18 15:41:42 +03:00
|
|
|
* @return false
|
|
|
|
*/
|
2015-05-15 10:07:39 +03:00
|
|
|
function httpGet(RequestInterface $request, ResponseInterface $response) {
|
|
|
|
$string = 'This is the WebDAV interface. It can only be accessed by ' .
|
2017-03-18 14:59:25 +03:00
|
|
|
'WebDAV clients such as the Nextcloud desktop sync client.';
|
2015-05-15 10:07:39 +03:00
|
|
|
$stream = fopen('php://memory','r+');
|
|
|
|
fwrite($stream, $string);
|
|
|
|
rewind($stream);
|
|
|
|
|
2015-08-25 19:07:40 +03:00
|
|
|
$response->setStatus(200);
|
2015-05-15 10:07:39 +03:00
|
|
|
$response->setBody($stream);
|
|
|
|
|
2015-02-18 15:41:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|