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 19:17:00 -0600
Message-ID: <CACuKZqHZyJXHEC31DmVGPmVYGn_BYuphTwtKaAi33qU6BWXRkA@mail.gmail.com>
To: Martin Thomson <martin.thomson@gmail.com>
Cc: Mark Nottingham <mnot@mnot.net>, "Roy T. Fielding" <fielding@gbiv.com>, HTTP Working Group <ietf-http-wg@w3.org>
In RFC2616, there's a clear distinction between
  1. a message without an entity body
  2. a message with an entity body of 0 bytes.
We should not remove the distinction

Quotes from RFC2616
=====

(HTTP messages) consist of ... possibly a message-body.

The message-body (if any) of an HTTP message is used to carry the entity-body

The presence of a message-body in a request is signaled by the
inclusion of a Content-Length or Transfer-Encoding header field in the
request's message-headers.

messages MAY transfer an entity

An entity consists of entity-header fields and an entity-body,
although some *responses* will only include the entity-headers.

An entity-body is only present in a message when a message-body is present

====

We can conclude that

If a request does not have "Content-Length" or "Transfer-Encoding", it
does not contain a message body, it does not contain an entity body,
it does not contain an entity.

If a request has "Content-Length: 0", it contains a message body of 0
bytes, it contain an entity body of 0 bytes, it contain an entity.

This is true regardless of the request method.

Zhong Yu


On Tue, Nov 27, 2012 at 6:10 PM, Martin Thomson
<martin.thomson@gmail.com> wrote:
> On 27 November 2012 14:58, Mark Nottingham <mnot@mnot.net> wrote:
>> 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 method does not define any meaning for the body (in which case the Content-Length header MAY be sent).
>
> IANAL, so this was hard to parse for me.  How about:
>
> --8<--
> The Content-Length header indicates the size of a message body as a
> decimal number of octets.  The sender SHOULD set Content-Length if:
>    o  the message is allowed to contain a body,
>    o  the Transfer-Encoding header field is not included, and
>    o  the size of the message body is known at the time that headers are sent.
> Messages that do not define a meaning for the body MAY either omit the
> Content-Length header field or include a value of 0.
> -->8--
>
> I'm leery of the "SHOULD" still.  It seems weak.  I'd almost go with
> MUST include and a fourth condition: the message size is unknown and
> the end of the body is signaled by closing the connection (in which
> case the Connection header MUST include the 'close' token).
>
Received on Wednesday, 28 November 2012 01:17:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 28 November 2012 01:17:30 GMT