Nextcloud云盘的httpPropFind方法WebDAV属性查找
WebDAV属性查找
此WebDAV方法请求有关uri资源或资源列表的信息
如果客户机希望接收单个资源的属性,它将添加一个带有0值的HTTP-Depth:header
如果值为1,则表示它还需要一个子资源列表(例如,目录中的文件)
请求主体包含一个XML数据结构,该结构具有客户机理解的属性列表
响应主体也是一个xml文档,包含关于每个uri资源和请求的属性的信息
它必须返回HTTP 207多状态代码
此函数所在文件:3rdparty/sabre/dav/lib/DAV/CorePlugin.php
function httpPropFind(RequestInterface $request, ResponseInterface $response) {
$path = $request->getPath();
$requestBody = $request->getBodyAsString();
if (strlen($requestBody)) {
try {
$propFindXml = $this->server->xml->expect('{DAV:}propfind', $requestBody);
} catch (ParseException $e) {
throw new BadRequest($e->getMessage(), null, $e);
}
} else {
$propFindXml = new Xml\Request\PropFind();
$propFindXml->allProp = true;
$propFindXml->properties = [];
}
$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->getPropertiesIteratorForPath($path, $propFindXml->properties, $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 interrupt the event chain and tell the server
// we've handled this method.
return false;
}
返回文件的:读写权限信息;分享文件的使用权限;文件的扩展信息,创建、修改、上传、类型等等Mime数据信息;