Most HTTP requests that have a request body, will also have a
header indicating how big the body will be. However, this is optional for some
cases, such as when Chunked Transfer Coding is used.
It’s useful for a client to not include a
Content-Length header for a few
different cases. For instance, a client might send a HTTP request body based
on a stream.
If a server does not support this feature, it can indicate this by sending back
411 Length Required.
In a situation like this, a recourse a client might have is to buffer the entire request to determine the real length.
HTTP/1.1 411 Length Required Content-Type: text/html Server: curveball/0.6.0 <h1>This server requires a Content-Length</h1>
- RFC7231, Section 6.5.10 - 411 Length Required