You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DummyGetResponsePlugin.php 2.1KB

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