412 Precondition Failed - HTTP 编辑
The HyperText Transfer Protocol (HTTP) 412 Precondition Failed
client error response code indicates that access to the target resource has been denied. This happens with conditional requests on methods other than GET
or HEAD
when the condition defined by the If-Unmodified-Since
or If-None-Match
headers is not fulfilled. In that case, the request, usually an upload or a modification of a resource, cannot be made and this error response is sent back.
Status
412 Precondition Failed
Examples
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
ETag: W/"0815"
Avoiding mid-air collisions
With the help of the ETag
and the If-Match
headers, you can detect mid-air edit collisions.
For example, when editing MDN, the current wiki content is hashed and put into an Etag
in the response:
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
When saving changes to a wiki page (posting data), the POST
request will contain the If-Match
header containing the ETag
values to check freshness against.
If-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"
If the hashes don't match, it means that the document has been edited in-between and a 412
Precondition Failed
error is thrown.
Specifications
Specification | Title |
---|---|
RFC 7232, section 4.2: 412 Precondition Failed | Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests |
Browser compatibility
BCD tables only load in the browser
The information below has been pulled from MDN's GitHub (https://github.com/mdn/browser-compat-data).
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论