Server.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\DAV\Connector\Sabre;
  8. /**
  9. * Class \OCA\DAV\Connector\Sabre\Server
  10. *
  11. * This class overrides some methods from @see \Sabre\DAV\Server.
  12. *
  13. * @see \Sabre\DAV\Server
  14. */
  15. class Server extends \Sabre\DAV\Server {
  16. /** @var CachingTree $tree */
  17. /**
  18. * @see \Sabre\DAV\Server
  19. */
  20. public function __construct($treeOrNode = null) {
  21. parent::__construct($treeOrNode);
  22. self::$exposeVersion = false;
  23. $this->enablePropfindDepthInfinity = true;
  24. }
  25. // Copied from 3rdparty/sabre/dav/lib/DAV/Server.php
  26. // Should be them exact same without the exception output.
  27. public function start(): void {
  28. try {
  29. // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
  30. // origin, we must make sure we send back HTTP/1.0 if this was
  31. // requested.
  32. // This is mainly because nginx doesn't support Chunked Transfer
  33. // Encoding, and this forces the webserver SabreDAV is running on,
  34. // to buffer entire responses to calculate Content-Length.
  35. $this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());
  36. // Setting the base url
  37. $this->httpRequest->setBaseUrl($this->getBaseUri());
  38. $this->invokeMethod($this->httpRequest, $this->httpResponse);
  39. } catch (\Throwable $e) {
  40. try {
  41. $this->emit('exception', [$e]);
  42. } catch (\Exception $ignore) {
  43. }
  44. }
  45. }
  46. }