http-parser icon indicating copy to clipboard operation
http-parser copied to clipboard

Always skip body for 1xx, 204, and 304 responses

Open azaretsky opened this issue 6 years ago • 4 comments

https://tools.ietf.org/html/rfc7230#section-3.3.3: ... any response with a 1xx (Informational), 204 (No Content), or 304 (Not Modified) status code is always terminated by the first empty line after the header fields, regardless of the header fields present in the message, and thus cannot contain a message body.

Fixes: https://github.com/nodejs/http-parser/issues/251

azaretsky avatar Mar 18 '19 01:03 azaretsky

It's quite hard to tell if this behavior change will affect anyone since it seems that these responses are rarely encountered in the wild if at all: 1xx, 204, and 304 responses without a declared message body length are already correctly handled by the parser, while 1xx and 204 with a message body are not legitimate according to the spec, and real servers often do not include content-length or transfer-encoidng in 304 responses (at least IIS, nginx and apache httpd don't).

So there's a great chance that this change is harmless but also purely cosmetic and no-one actually needs it.

azaretsky avatar Mar 19 '19 15:03 azaretsky

cc @indutny - perhaps you can weigh in?

bnoordhuis avatar Apr 09 '19 09:04 bnoordhuis

I think it might be too hard to propagate description this change to the consumers of http-parser. In order to properly do it, we'll have to do major release.

@nodejs/http : do we consider major release a possibility, or would we prefer to stick with llhttp and do majority of changes there instead?

indutny avatar Apr 14 '19 02:04 indutny

Just for the record: I will try to keep this branch rebased on top of the current master in case anyone wants to use it before the next major release.

azaretsky avatar May 04 '19 14:05 azaretsky