412 Precondition Failed

The HTTP 412 status code happens when a client can’t meet a precondition in a conditional request.

HTTP supports conditional requests (requests that contain one or more If- headers), which are often used in caching. Conditional requests can also be used to verify the integrity of files via checksums.

If a client doesn’t meet one of the preconditions, the server returns 412 Precondition Failed.

GET /git HTTP/2

HTTP/2 200 OK
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"

When a client wants to update the resource, it can include the If-Match to make sure no one has updated the resource in the interim otherwise, that update would be lost (lost update problem is the term-of-art).

PUT /git
If-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"

If the current hash of the resource (ETag) doesn’t match the hash in the If-Match header, the server will respond with 412 Precondition Failed.

See also

Interested in no-nonsense technical guides?

No spyware, no promotional emails, or keyword-stuffed junk. I will only send you a single email when I've got something interesting to say. Unsubscribe anytime.

You can also subscribe to the Atom feed (it's like RSS, but better).