2015-02-18 07:41:42 -05:00
|
|
|
<?php
|
2024-05-27 11:39:07 -04:00
|
|
|
|
2015-02-18 07:41:42 -05:00
|
|
|
/**
|
2024-05-27 11:39:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-02-18 07:41:42 -05:00
|
|
|
*/
|
2015-08-30 13:13:01 -04:00
|
|
|
namespace OCA\DAV\Connector\Sabre;
|
2020-04-09 05:48:10 -04:00
|
|
|
|
2024-12-14 04:32:14 -05:00
|
|
|
use OCP\AppFramework\Http;
|
2022-04-12 08:01:13 -04:00
|
|
|
use Sabre\DAV\Server;
|
2015-05-15 03:07:39 -04:00
|
|
|
use Sabre\HTTP\RequestInterface;
|
2019-11-22 14:52:10 -05:00
|
|
|
use Sabre\HTTP\ResponseInterface;
|
2015-02-18 07:41:42 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class DummyGetResponsePlugin is a plugin used to not show a "Not implemented"
|
2017-04-12 00:16:27 -04:00
|
|
|
* error to clients that rely on verifying the functionality of the Nextcloud
|
2015-02-18 07:41:42 -05: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 13:13:01 -04:00
|
|
|
* @package OCA\DAV\Connector\Sabre
|
2015-02-18 07:41:42 -05:00
|
|
|
*/
|
|
|
|
|
class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
|
2022-05-05 18:01:08 -04:00
|
|
|
protected ?Server $server = null;
|
2015-02-18 07:41:42 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param \Sabre\DAV\Server $server
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2020-04-10 10:51:06 -04:00
|
|
|
public function initialize(\Sabre\DAV\Server $server) {
|
2015-02-18 07:41:42 -05:00
|
|
|
$this->server = $server;
|
2015-05-15 03:07:39 -04:00
|
|
|
$this->server->on('method:GET', [$this, 'httpGet'], 200);
|
2015-02-18 07:41:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-05-15 03:07:39 -04:00
|
|
|
* @param RequestInterface $request
|
|
|
|
|
* @param ResponseInterface $response
|
2015-02-18 07:41:42 -05:00
|
|
|
* @return false
|
|
|
|
|
*/
|
2020-04-10 10:51:06 -04:00
|
|
|
public function httpGet(RequestInterface $request, ResponseInterface $response) {
|
2015-05-15 03:07:39 -04:00
|
|
|
$string = 'This is the WebDAV interface. It can only be accessed by '
|
2017-03-18 07:59:25 -04:00
|
|
|
. 'WebDAV clients such as the Nextcloud desktop sync client.';
|
2015-05-15 03:07:39 -04:00
|
|
|
$stream = fopen('php://memory', 'r+');
|
|
|
|
|
fwrite($stream, $string);
|
|
|
|
|
rewind($stream);
|
|
|
|
|
|
2024-12-14 04:32:14 -05:00
|
|
|
$response->setStatus(Http::STATUS_OK);
|
2015-05-15 03:07:39 -04:00
|
|
|
$response->setBody($stream);
|
|
|
|
|
|
2015-02-18 07:41:42 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|