nodejs / http-parser

http request/response parser for c
MIT License
6.35k stars 1.54k forks source link

Allow duplicated Content-Length with the same value #460

Open obatysh opened 5 years ago

indutny commented 5 years ago

Hello!

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

obatysh commented 5 years ago

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.

indutny commented 5 years ago

Good point!

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

ploxiln commented 5 years ago

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

bnoordhuis commented 5 years ago

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