208 Already Reported
用法
当客户端在 207 multi-status 消息体内部收到 208 Already Reported 时,说明该资源已在同一响应的更早位置被描述过。对于这个重复条目,不再提供额外的细节。
该状态码专为 WebDAV Binding Extensions 而存在。绑定到同一集合内多个位置的资源,会完整出现一次,并以 208 Already Reported 出现一次,从而在 Depth: infinity 请求遇到自我引用的资源时打破潜在的递归。
仅限 WebDAV
208 Already Reported 状态码仅出现在 207 multi-status 响应体内部。服务器绝不会将 208 作为顶层 HTTP 响应状态发送。
示例
客户端发送一个带有 Depth: infinity 的 PROPFIND 请求,以枚举 /main/ 集合。资源 /main/dependent 与 /main/ 自身绑定到同一个底层资源。
服务器先返回 /main/ 的完整细节,然后对 /main/dependent 返回 208 Already Reported,以打破递归循环。
请求
PROPFIND /main/ HTTP/1.1
Host: example.com
Depth: infinity
DAV: bind
Content-Type: application/xml; charset="utf-8"
Content-Length: 139
<?xml version="1.0" encoding="utf-8" ?>
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:name/>
<d:link/>
</d:prop>
</d:propfind>
响应
HTTP/1.1 207 Multi-Status
Content-Type: application/xml; charset="utf-8"
Content-Length: 568
<?xml version="1.0" encoding="utf-8" ?>
<d:multistatus xmlns:d="DAV:">
<d:response>
<d:href>http://example.re/main/</d:href>
<d:propstat>
<d:prop>
<d:name>Main Resource</d:name>
<d:resource-id>
<href>urn:uuid:1234-0000</href>
</d:resource-id>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>
http://example.re/main/dependent
</d:href>
<d:propstat>
<d:prop>
<d:name>Main Resource</d:name>
<d:resource-id>
<href>urn:uuid:1234-0000</href>
</d:resource-id>
</d:prop>
<d:status>
HTTP/1.1 208 Already Reported
</d:status>
</d:propstat>
</d:response>
</d:multistatus>
代码参考
.NET
HttpStatusCode.AlreadyReported
Rust
http::StatusCode::ALREADY_REPORTED
Rails
:already_reported
Go
http.StatusAlreadyReported
Symfony
Response::HTTP_ALREADY_REPORTED
Python3.5+
http.HTTPStatus.ALREADY_REPORTED
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_ALREADY_REPORTED
Angular
@angular/common/http/HttpStatusCode.AlreadyReported