Lines Matching +full:fetch +full:- +full:depth
28 …* Infinity is used for some request supporting the HTTP Depth header and indicates that the operat…
30 const DEPTH_INFINITY = -1;
85 * plugins override this. For example, the WebDAV-Sync sync-collection
86 * report will set this to 'report-sync-collection'.
93 * This is a list of properties that are always server-controlled, and
110 '{DAV:}quota-available-bytes',
111 '{DAV:}quota-used-bytes',
114 '{DAV:}supported-privilege-set',
115 '{DAV:}current-user-privilege-set',
117 '{DAV:}acl-restrictions',
118 '{DAV:}inherited-acl-set',
121 '{DAV:}supported-method-set',
122 '{DAV:}supported-report-set',
125 '{DAV:}sync-token',
131 '{http://sabredav.org/ns}sync-token',
157 * This property allows the usage of Depth: infinity on PROPFIND requests.
159 * By default Depth: infinity is treated as Depth: 1. Allowing Depth:
197 * the nodes in the array as top-level children.
204 $this->tree = $treeOrNode;
206 $this->tree = new Tree($treeOrNode);
218 $this->tree = new Tree($root);
222 $this->tree = new Tree($root);
227 $this->xml = new Xml\Service();
228 $this->sapi = new HTTP\Sapi();
229 $this->httpResponse = new HTTP\Response();
230 $this->httpRequest = $this->sapi->getRequest();
231 $this->addPlugin(new CorePlugin());
244 // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
249 // to buffer entire responses to calculate Content-Length.
250 $this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());
253 $this->httpRequest->setBaseUrl($this->getBaseUri());
254 $this->invokeMethod($this->httpRequest, $this->httpResponse);
259 $this->emit('exception', [$e]);
262 $DOM = new \DOMDocument('1.0', 'utf-8');
263 $DOM->formatOutput = true;
265 $error = $DOM->createElementNS('DAV:', 'd:error');
266 $error->setAttribute('xmlns:s', self::NS_SABREDAV);
267 $DOM->appendChild($error);
271 return htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8');
276 … $error->appendChild($DOM->createElement('s:sabredav-version', $h(Version::VERSION)));
279 $error->appendChild($DOM->createElement('s:exception', $h(get_class($e))));
280 $error->appendChild($DOM->createElement('s:message', $h($e->getMessage())));
281 if ($this->debugExceptions) {
282 $error->appendChild($DOM->createElement('s:file', $h($e->getFile())));
283 $error->appendChild($DOM->createElement('s:line', $h($e->getLine())));
284 $error->appendChild($DOM->createElement('s:code', $h($e->getCode())));
285 … $error->appendChild($DOM->createElement('s:stacktrace', $h($e->getTraceAsString())));
288 if ($this->debugExceptions) {
290 while ($previous = $previous->getPrevious()) {
291 $xPrevious = $DOM->createElement('s:previous-exception');
292 … $xPrevious->appendChild($DOM->createElement('s:exception', $h(get_class($previous))));
293 … $xPrevious->appendChild($DOM->createElement('s:message', $h($previous->getMessage())));
294 … $xPrevious->appendChild($DOM->createElement('s:file', $h($previous->getFile())));
295 … $xPrevious->appendChild($DOM->createElement('s:line', $h($previous->getLine())));
296 … $xPrevious->appendChild($DOM->createElement('s:code', $h($previous->getCode())));
297 … $xPrevious->appendChild($DOM->createElement('s:stacktrace', $h($previous->getTraceAsString())));
298 $error->appendChild($xPrevious);
305 $httpCode = $e->getHTTPCode();
306 $e->serialize($this, $error);
307 $headers = $e->getHTTPHeaders($this);
315 $headers['Content-Type'] = 'application/xml; charset=utf-8';
317 $this->httpResponse->setStatus($httpCode);
318 $this->httpResponse->setHeaders($headers);
319 $this->httpResponse->setBody($DOM->saveXML());
320 $this->sapi->sendResponse($this->httpResponse);
335 if ($uri[strlen($uri) - 1] !== '/')
338 $this->baseUri = $uri;
349 if (is_null($this->baseUri)) $this->baseUri = $this->guessBaseUri();
350 return $this->baseUri;
364 $pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO');
365 $uri = $this->httpRequest->getRawServerValue('REQUEST_URI');
382 if (substr($decodedUri, strlen($decodedUri) - strlen($pathInfo)) === $pathInfo) {
383 $baseUri = substr($decodedUri, 0, strlen($decodedUri) - strlen($pathInfo));
406 $this->plugins[$plugin->getPluginName()] = $plugin;
407 $plugin->initialize($this);
421 if (isset($this->plugins[$name]))
422 return $this->plugins[$name];
435 return $this->plugins;
440 * Returns the PSR-3 logger object.
446 if (!$this->logger) {
447 $this->logger = new NullLogger();
449 return $this->logger;
463 $method = $request->getMethod();
465 if (!$this->emit('beforeMethod:' . $method, [$request, $response])) return;
466 if (!$this->emit('beforeMethod', [$request, $response])) return;
469 $response->setHeader('X-Sabre-Version', Version::VERSION);
472 $this->transactionType = strtolower($method);
474 if (!$this->checkPreconditions($request, $response)) {
475 $this->sapi->sendResponse($response);
479 if ($this->emit('method:' . $method, [$request, $response])) {
480 if ($this->emit('method', [$request, $response])) {
491 if (!$this->emit('afterMethod:' . $method, [$request, $response])) return;
492 if (!$this->emit('afterMethod', [$request, $response])) return;
494 if ($response->getStatus() === null) {
498 $this->sapi->sendResponse($response);
499 $this->emit('afterResponse', [$request, $response]);
529 $this->tree->getNodeForPath($path);
535 …foreach ($this->plugins as $plugin) $methods = array_merge($methods, $plugin->getHTTPMethods($path…
549 return $this->calculateUri($this->httpRequest->getUrl());
559 * * uri-decodes the path
574 $baseUri = Uri\normalize($this->getBaseUri());
588 …ception\Forbidden('Requested uri (' . $uri . ') is out of base uri (' . $this->getBaseUri() . ')');
595 * Returns the HTTP depth header
597 …* This method returns the contents of the HTTP depth request header. If the depth header was 'infi…
598 …s possible to supply a default depth value, which is used when the depth header has invalid conten…
606 $depth = $this->httpRequest->getHeader('Depth');
608 if (is_null($depth)) return $default;
610 if ($depth == 'infinity') return self::DEPTH_INFINITY;
614 if (!ctype_digit($depth)) return $default;
616 return (int)$depth;
623 * This method returns null if there is no well-formed HTTP range request
636 $range = $this->httpRequest->getHeader('range');
639 // Matching "Range: bytes=1234-5678: both numbers are optional
641 if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i', $range, $matches)) return null;
656 * http://tools.ietf.org/html/draft-snell-http-prefer-14
662 * 'return-asynch' => true,
663 * 'return-minimal' => true,
664 * 'return-representation' => true,
671 * 'return-minimal' if the brief header was set to 't'.
682 'respond-async' => false,
691 if ($prefer = $this->httpRequest->getHeader('Prefer')) {
698 } elseif ($this->httpRequest->getHeader('Brief') == 't') {
714 * * destination - Destination path
715 …* * destinationExists - Whether or not the destination is an existing url (and should therefore …
720 * non-collection.
732 …if (!$request->getHeader('Destination')) throw new Exception\BadRequest('The destination header wa…
733 $destination = $this->calculateUri($request->getHeader('Destination'));
734 $overwrite = $request->getHeader('Overwrite');
744 $destinationParent = $this->tree->getNodeForPath($destinationDir);
754 $destinationNode = $this->tree->getNodeForPath($destination);
767 $requestPath = $request->getPath();
801 $result = $this->getPropertiesForPath($path, $propertyNames, 0);
811 * A kid-friendly way to fetch properties for a node's children.
825 foreach ($this->getPropertiesForPath($path, $propertyNames, 1) as $k => $row) {
852 '{DAV:}getcontenttype' => 'Content-Type',
853 '{DAV:}getcontentlength' => 'Content-Length',
854 '{DAV:}getlastmodified' => 'Last-Modified',
858 $properties = $this->getProperties($path, array_keys($propertyMap));
869 $headers[$header] = HTTP\Util::toHTTPDate($properties[$property]->getTime());
889 $newDepth = $propFind->getDepth();
890 $path = $propFind->getPath();
893 $newDepth--;
896 $propertyNames = $propFind->getRequestedProperties();
899 foreach ($this->tree->getChildren($path) as $childNode) {
901 $subPath = $path . '/' . $childNode->getName();
903 $subPath = $childNode->getName();
913 foreach ($this->generatePathNodes($subPropFind) as $subItem) {
928 * If a depth of 1 is requested child elements will also be returned.
932 * @param int $depth
938 function getPropertiesForPath($path, $propertyNames = [], $depth = 0) { argument
940 … return iterator_to_array($this->getPropertiesIteratorForPath($path, $propertyNames, $depth));
950 * If a depth of 1 is requested child elements will also be returned.
954 * @param int $depth
957 function getPropertiesIteratorForPath($path, $propertyNames = [], $depth = 0) { argument
959 …// The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not e…
960 if (!$this->enablePropfindDepthInfinity && $depth != 0) $depth = 1;
965 $propFind = new PropFind($path, (array)$propertyNames, $depth, $propFindType);
967 $parentNode = $this->tree->getNodeForPath($path);
974 if (($depth > 0 || $depth === self::DEPTH_INFINITY) && $parentNode instanceof ICollection) {
975 … $propFindRequests = $this->generatePathNodes(clone $propFind, current($propFindRequests));
981 $r = $this->getPropertiesByNode($propFind, $node);
983 $result = $propFind->getResultForMultiStatus();
984 $result['href'] = $propFind->getPath();
989 // principals. This is non-standard, but we support it.
990 $resourceType = $this->getResourceTypeForNode($node);
1020 $nodes = $this->tree->getMultipleNodes($paths);
1025 $r = $this->getPropertiesByNode($propFind, $node);
1027 $result[$path] = $propFind->getResultForMultiStatus();
1030 $resourceType = $this->getResourceTypeForNode($node);
1059 return $this->emit('propFind', [$propFind, $node]);
1064 * This method is invoked by sub-systems creating a new file.
1081 if (!$this->emit('beforeBind', [$uri])) return false;
1083 $parent = $this->tree->getNodeForPath($dir);
1094 if (!$this->emit('beforeCreateFile', [$uri, &$data, $parent, &$modified])) return false;
1096 $etag = $parent->createFile($name, $data);
1100 $this->tree->markDirty($dir . '/' . $name);
1102 $this->emit('afterBind', [$uri]);
1103 $this->emit('afterCreateFile', [$uri, $parent]);
1109 * This method is invoked by sub-systems updating a file.
1120 $node = $this->tree->getNodeForPath($uri);
1128 if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) return false;
1130 $etag = $node->put($data);
1132 $this->emit('afterWriteContent', [$uri, $node]);
1140 * This method is invoked by sub-systems creating a new directory.
1147 $this->createCollection($uri, new MkCol(['{DAV:}collection'], []));
1164 $parent = $this->tree->getNodeForPath($parentUri);
1178 $parent->getChild($newName);
1188 if (!$this->emit('beforeBind', [$uri])) return;
1197 $parent->createExtendedCollection($newName, $mkCol);
1206 if (count($mkCol->getResourceType()) > 1) {
1210 $parent->createDirectory($newName);
1217 if ($mkCol->getRemainingMutations()) {
1218 $this->emit('propPatch', [$uri, $mkCol]);
1220 $success = $mkCol->commit();
1223 $result = $mkCol->getResult();
1240 $this->tree->markDirty($parentUri);
1241 $this->emit('afterBind', [$uri]);
1248 * The properties array must be a list of properties. Array-keys are
1249 * property names in clarknotation, array-values are it's values.
1265 $this->emit('propPatch', [$path, $propPatch]);
1266 $propPatch->commit();
1268 return $propPatch->getResult();
1276 * * If-Match
1277 * * If-None-Match
1278 * * If-Modified-Since
1279 * * If-Unmodified-Since
1287 * related to If-None-Match, If-Match and If-Unmodified Since. It will
1288 * set the status to 304 Not Modified for If-Modified_since.
1296 $path = $request->getPath();
1301 if ($ifMatch = $request->getHeader('If-Match')) {
1303 // If-Match contains an entity tag. Only if the entity-tag
1305 // If the entity-tag is '*' we are only allowed to make the
1308 $node = $this->tree->getNodeForPath($path);
1310 …hrow new Exception\PreconditionFailed('An If-Match header was specified and the resource did not e…
1324 $etag = $node instanceof IFile ? $node->getETag() : null;
1337 if ($etag) $response->setHeader('ETag', $etag);
1338 … Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETa…
1343 if ($ifNoneMatch = $request->getHeader('If-None-Match')) {
1345 // The If-None-Match header contains an ETag.
1352 $node = $this->tree->getNodeForPath($path);
1364 $etag = $node instanceof IFile ? $node->getETag() : null;
1378 if ($etag) $response->setHeader('ETag', $etag);
1379 if ($request->getMethod() === 'GET') {
1380 $response->setStatus(304);
1383 …eption\PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was s…
1390 if (!$ifNoneMatch && ($ifModifiedSince = $request->getHeader('If-Modified-Since'))) {
1392 // The If-Modified-Since header contains a date. We
1396 // Note that this header only has to be checked if there was no If-None-Match header
1402 $node = $this->tree->getNodeForPath($path);
1404 $lastMod = $node->getLastModified();
1408 $response->setStatus(304);
1409 $response->setHeader('Last-Modified', HTTP\Util::toHTTPDate($lastMod));
1416 if ($ifUnmodifiedSince = $request->getHeader('If-Unmodified-Since')) {
1418 // The If-Unmodified-Since will allow allow the request if the
1425 $node = $this->tree->getNodeForPath($path);
1427 $lastMod = $node->getLastModified();
1431 …ditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since t…
1439 // urls, ETags and so-called 'state tokens'.
1441 // Examples of state tokens include lock-tokens (as defined in rfc4918)
1442 // and sync-tokens (as defined in rfc6578).
1446 $ifConditions = $this->getIfConditions($request);
1457 $this->emit('validateTokens', [$request, &$ifConditions]);
1483 $node = $this->tree->getNodeForPath($uri);
1484 $etagValid = $node instanceof IFile && $node->getETag() == $token['etag'];
1513 * * uri - the uri the condition applies to.
1514 * * tokens - The lock token. another 2 dimensional array containing 3 elements
1518 * If: (<opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2>)
1529 * 'token' => 'opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2',
1539 …* If: </path/> (Not <opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2> ["Im An ETag"]) (["Anot…
1550 * 'token' => 'opaquelocktoken:181d4fae-7d8c-11d0-a765-00a0c91e6bf2',
1580 $header = $request->getHeader('If');
1596 $conditions[count($conditions) - 1]['tokens'][] = [
1604 $realUri = $request->getPath();
1606 $realUri = $this->calculateUri($match['uri']);
1637 foreach ($this->resourceTypeMapping as $className => $resourceType) {
1659 $w = $this->xml->getWriter();
1660 $w->openMemory();
1661 $w->contextUri = $this->baseUri;
1662 $w->startDocument();
1664 $w->startElement('{DAV:}multistatus');
1677 $w->write([
1682 $w->endElement();
1684 return $w->outputMemory();