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

Allow duplicated Content-Length with the same value

Open obatysh opened this issue 5 years ago • 5 comments

obatysh avatar Dec 20 '18 12:12 obatysh

Hello!

Thank you for submitting this patch. Wouldn't allowing duplicate content-length header be a violation of protocol specification?

indutny avatar Dec 21 '18 19:12 indutny

RFC https://tools.ietf.org/html/rfc7230#page-31 says that duplicate Content-Length fields with the same decimal value can be either rejected as invalid or accepted by replacing duplicate with a single valid Content-Length field. So, it is not a violation, it is one of the possible options. Not sure about "replacement" implementation, maybe this pull-request should be improved not to report the Content-Length field second time.

obatysh avatar Dec 22 '18 16:12 obatysh

Good point!

I'd love to hear opinion of @nodejs/http on that? Would we prefer to reject it or parse it?

indutny avatar Dec 22 '18 16:12 indutny

it's worth noting that this costs an additional 8 bytes per struct http_parser

ploxiln avatar Dec 23 '18 07:12 ploxiln

Yes. That means it breaks ABI and can't land in a v2.x release. See discussion in #435.

bnoordhuis avatar Dec 23 '18 16:12 bnoordhuis