WebDAV 中 GET 和 PROPFIND 的区别

Difference between GET and PROPFIND in WebDAV

根据 WebDAV 规范 (RFC 4918):

The semantics of GET are unchanged when applied to a collection, since GET is defined as, "retrieve whatever information (in the form of an entity) is identified by the Request-URI" [RFC2616].

和 PROPFIND

retrieves properties defined on the resource identified by the Request-URI.

所以 GET 和 PROPFIND 或多或少地检索了资源的信息。从这个意义上说,GET 和 PROPFIND 之间有什么主要区别吗?什么时候应该使用一个而不是另一个。

您所指的那一段解释了它:

GET, when applied to a collection, may return the contents of an "index.html" resource, a human-readable view of the contents of the collection, or something else altogether.

GET 的行为与历史一样,以保持向后兼容性。它通常会 return 一个 "index" 页面(文件 index.htmlindex.php 或类似文件)或者它会自动呈现一个 HTML 包含目录内容的页面(一个文件列表)。这意味着 WebDAV 服务器可以 运行 在与 HTTP 服务器相同的端口上(= 作为 HTTP 服务器的扩展),现有 HTTP 请求的行为相同。

虽然根据 WebDAV 规范,WebDAV PROPFIND 请求将 return 一个精确定义的、机器可读的 XML 文档。


如果您正在实施 WebDAV 客户端或服务器,您只对 PROPFIND 感兴趣。 GET 响应没有定义的格式(甚至没有内容),因此应用程序无法对其进行解析。

WebDAV PROPFIND 方法用于检索 URI 提及的资源的属性。

HTTP GET 方法可以 return 生成的数据而不是资源的源文本,以防它指向数据生成资源。请参阅 RFC 2616 - 超文本传输​​协议中的以下文本。

The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process. Source - RFC 2616