Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DummyGetResponsePlugin.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wickert <cwickert@suse.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCA\DAV\Connector\Sabre;
  28. use Sabre\DAV\Server;
  29. use Sabre\HTTP\RequestInterface;
  30. use Sabre\HTTP\ResponseInterface;
  31. /**
  32. * Class DummyGetResponsePlugin is a plugin used to not show a "Not implemented"
  33. * error to clients that rely on verifying the functionality of the Nextcloud
  34. * WebDAV backend using a simple GET to /.
  35. *
  36. * This is considered a legacy behaviour and implementers should consider sending
  37. * a PROPFIND request instead to verify whether the WebDAV component is working
  38. * properly.
  39. *
  40. * FIXME: Remove once clients are all compliant.
  41. *
  42. * @package OCA\DAV\Connector\Sabre
  43. */
  44. class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
  45. protected ?Server $server = null;
  46. /**
  47. * @param \Sabre\DAV\Server $server
  48. * @return void
  49. */
  50. public function initialize(\Sabre\DAV\Server $server) {
  51. $this->server = $server;
  52. $this->server->on('method:GET', [$this, 'httpGet'], 200);
  53. }
  54. /**
  55. * @param RequestInterface $request
  56. * @param ResponseInterface $response
  57. * @return false
  58. */
  59. public function httpGet(RequestInterface $request, ResponseInterface $response) {
  60. $string = 'This is the WebDAV interface. It can only be accessed by ' .
  61. 'WebDAV clients such as the Nextcloud desktop sync client.';
  62. $stream = fopen('php://memory', 'r+');
  63. fwrite($stream, $string);
  64. rewind($stream);
  65. $response->setStatus(200);
  66. $response->setBody($stream);
  67. return false;
  68. }
  69. }