Forums » Development »
[Solved] Why reject empty POST request without a Content-length?
Added by nickbnf over 11 years ago
Hi all,
lighttpd rejects POST requests with an empty body but without an explicit "Content-length: 0" field, sending back a 411 (see request.c:1117)
Reading RFC2616, I can't find anything explicitely forbidding this kind of request.
Is there a specific reason why this behaviour has been implemented?
Thanks a lot
Replies (4)
RE: Why reject empty POST request without a Content-length? - Added by darix over 11 years ago
why do you need it?
RE: Why reject empty POST request without a Content-length? - Added by nickbnf over 11 years ago
My client (a third party library I have no control over) sends empty POST messages, without adding the Content-length field. Correct me if I'm wrong, but it seems to me it is allowed since there is no body.
Those requests fail with lighttpd, so I'm trying to understand why it has been implemented this way.
RE: Why reject empty POST request without a Content-length? - Added by stbuehler over 11 years ago
In my reading POST requires a body; it can be empty, but it is still required. An empty body is not the same as no body in my reading, and there is nothing (afaics) in the spec that says "no body" is to be interpreted as "empty body".
RE: Why reject empty POST request without a Content-length? - Added by gstrauss over 8 years ago
POST requests are required by the RFC to have a request body, even if that body is empty. Therefore, Content-Length: 0 must be sent, OR an HTTP/1.1 request must be sent with Transfer-Encoding: chunked. With lighttpd 1.4.44, lighttpd supports Transfer-Encoding: chunked being sent by client request. Prior lighttpd versions would return 411 Length Required, which is a valid, RFC-compliant response, although supporting Transfer-Encoding: chunked is, of course, preferable.