From 8cb968c4b03e5d5462edec56f31625e9f15a6a15 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Jan 2020 09:18:07 +0000 Subject: composer update sabre/dav --- vendor/sabre/dav/lib/DAV/Server.php | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'vendor/sabre/dav/lib/DAV/Server.php') diff --git a/vendor/sabre/dav/lib/DAV/Server.php b/vendor/sabre/dav/lib/DAV/Server.php index 09760e9d1..69b3bb3f2 100644 --- a/vendor/sabre/dav/lib/DAV/Server.php +++ b/vendor/sabre/dav/lib/DAV/Server.php @@ -14,6 +14,7 @@ use Sabre\HTTP; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; use Sabre\Uri; +use Sabre\Xml\Writer; /** * Main DAV server class. @@ -184,6 +185,15 @@ class Server implements LoggerAwareInterface, EmitterInterface */ public static $exposeVersion = true; + /** + * If this setting is turned on, any multi status response on any PROPFIND will be streamed to the output buffer. + * This will be beneficial for large result sets which will no longer consume a large amount of memory as well as + * send back data to the client earlier. + * + * @var bool + */ + public static $streamMultiStatus = false; + /** * Sets up the server. * @@ -1628,19 +1638,38 @@ class Server implements LoggerAwareInterface, EmitterInterface // {{{ XML Readers & Writers /** - * Generates a WebDAV propfind response body based on a list of nodes. + * Returns a callback generating a WebDAV propfind response body based on a list of nodes. * * If 'strip404s' is set to true, all 404 responses will be removed. * * @param array|\Traversable $fileProperties The list with nodes * @param bool $strip404s * - * @return string + * @return callable|string */ public function generateMultiStatus($fileProperties, $strip404s = false) { $w = $this->xml->getWriter(); + if (self::$streamMultiStatus) { + return function () use ($fileProperties, $strip404s, $w) { + $w->openUri('php://output'); + $this->writeMultiStatus($w, $fileProperties, $strip404s); + $w->flush(); + }; + } $w->openMemory(); + $this->writeMultiStatus($w, $fileProperties, $strip404s); + + return $w->outputMemory(); + } + + /** + * @param Writer $w + * @param $fileProperties + * @param bool $strip404s + */ + private function writeMultiStatus(Writer $w, $fileProperties, bool $strip404s) + { $w->contextUri = $this->baseUri; $w->startDocument(); @@ -1662,7 +1691,6 @@ class Server implements LoggerAwareInterface, EmitterInterface ]); } $w->endElement(); - - return $w->outputMemory(); + $w->endDocument(); } } -- cgit v1.2.3