예제 #1
0
 /**
  * WebDAV PROPFIND
  *
  * This WebDAV method requests information about an uri resource, or a list of resources
  * If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value
  * If the value is 1, it means that it also expects a list of sub-resources (e.g.: files in a directory)
  *
  * The request body contains an XML data structure that has a list of properties the client understands
  * The response body is also an xml document, containing information about every uri resource and the requested properties
  *
  * It has to return a HTTP 207 Multi-status status code
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return void
  */
 function httpPropfind(RequestInterface $request, ResponseInterface $response)
 {
     $path = $request->getPath();
     $requestedProperties = $this->server->parsePropFindRequest($request->getBodyAsString());
     $depth = $this->server->getHTTPDepth(1);
     // The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled
     if (!$this->server->enablePropfindDepthInfinity && $depth != 0) {
         $depth = 1;
     }
     $newProperties = $this->server->getPropertiesForPath($path, $requestedProperties, $depth);
     // This is a multi-status response
     $response->setStatus(207);
     $response->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $response->setHeader('Vary', 'Brief,Prefer');
     // Normally this header is only needed for OPTIONS responses, however..
     // iCal seems to also depend on these being set for PROPFIND. Since
     // this is not harmful, we'll add it.
     $features = ['1', '3', 'extended-mkcol'];
     foreach ($this->server->getPlugins() as $plugin) {
         $features = array_merge($features, $plugin->getFeatures());
     }
     $response->setHeader('DAV', implode(', ', $features));
     $prefer = $this->server->getHTTPPrefer();
     $minimal = $prefer['return-minimal'];
     $data = $this->server->generateMultiStatus($newProperties, $minimal);
     $response->setBody($data);
     // Sending back false will interupt the event chain and tell the server
     // we've handled this method.
     return false;
 }