Re: Distinguishing 0-byte request body in HTTP/2

Hi, Willy, Mark, Roy,

Thank you for your insights.

2016-09-15 16:00 GMT+09:00 Willy Tarreau <w@1wt.eu>:

> I'd be tempted to simplify this as "if you're sending a body even an empty
> one, announce its size in content-length". Methods like POST and PUT expect
> a message body so that should always be done.

Although there is no distinction between a request with a zero-byte
body and a request without a body, I agree that it might be a good
idea to send `content-length: 0` for some methods (e.g. POST), whereas
for others it would be a good idea to _not_ send `content-length: 0`
(e.g. GET).

I now understand that suggestions for existing methods are given in
RFC 7231. For example, section 4.3.1 states:

   A payload within a GET request message has no defined semantics;
   sending a payload body on a GET request might cause some existing
   implementations to reject the request.

Similar statements exist for other methods.

And the recommendation made for methods that are defined outside of
HTTP/1.1 is defined in section 8.1.2 (thanks to Mark for pointing it
out), quote:

   Since message parsing (Section 3.3 of [RFC7230]) needs to be
   independent of method semantics (aside from responses to HEAD),
   definitions of new methods cannot change the parsing algorithm or
   prohibit the presence of a message body on either the request or the
   response message.  Definitions of new methods can specify that only a
   zero-length message body is allowed by requiring a Content-Length
   header field with a value of "0".


> Regards,
> Willy



-- 
Kazuho Oku

Received on Tuesday, 20 September 2016 01:07:46 UTC