HTTP 411 Length Required vs 412 Precondition Failed
Both HTTP 411 (Length Required) and 412 (Precondition Failed) belong to the 4xx Client Error category. 411 indicates that the server refuses to accept the request without a Content-Length header. Meanwhile, 412 means that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
Description
The server refuses to accept the request without a Content-Length header.
When You See It
When sending a request body without specifying Content-Length.
How to Fix
Include a Content-Length header in your request.
Description
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
When You See It
When using conditional requests with ETags and the resource has changed.
How to Fix
Refresh the ETag/Last-Modified value and retry with updated preconditions.
Key Differences
HTTP 411: The server refuses to accept the request without a Content-Length header.
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
You encounter 411 when when sending a request body without specifying Content-Length.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
When to Use Which
For 411 (Length Required): Include a Content-Length header in your request. For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions.