W3C home > Mailing lists > Public > ietf-http-wg@w3.org > October to December 2012

Re: P1: Content-Length SHOULD be sent

From: Zhong Yu <zhong.j.yu@gmail.com>
Date: Tue, 27 Nov 2012 09:03:22 -0600
Message-ID: <CACuKZqEB2EcgXKmL5bkFBZ8p5JxPTqp=Ky3CSKx+StH333tj=g@mail.gmail.com>
To: Mark Nottingham <mnot@mnot.net>
Cc: HTTP Working Group <ietf-http-wg@w3.org>
On Mon, Nov 26, 2012 at 11:21 PM, Mark Nottingham <mnot@mnot.net> wrote:
> Currently, p1 says:
>
>> When a message is allowed to contain a message body, does not have a Transfer-Encoding header field, and has a payload body length that is known to the sender before the message header section has been sent, the sender should send a Content-Length header field to indicate the length of the payload body as a decimal number of octets.
>
> This unqualified SHOULD leads people to convoluted readings of the spec where Content-Length is required to be sent on a GET request:
>   https://github.com/kennethreitz/requests/issues/223#issuecomment-10745532
>
> Proposal:
>
>> When a message is allowed to contain a body, does not have a Transfer-Encoding header field, and has a payload body length that is known to the sender before the message header section has been sent, the sender should send a Content-Length header field to indicate the length of the payload body as a decimal number of octets, unless the message is a request and the payload length is zero (in which case the Content-Length header MAY be sent).

Isn't there a semantic difference between a request without a payload
and a request with an empty payload?

If a POST request payload is empty (which is perfectly valid, e.g. an
HTML form post without parameters), and it doesn't include
"Content-Length:0", it may break server implementations, because the
server checks whether a request has an "entity" based on
Content-Length/Transfer-Encoding, regardless of request method. If
Content-Length:0 is missing, the server will think that this is a POST
request without "entity", which it is probably unprepared for.

Zhong Yu

>
>
> --
> Mark Nottingham   http://www.mnot.net/
>
>
>
>
Received on Tuesday, 27 November 2012 15:03:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 November 2012 15:04:04 GMT