openwrt / uhttpd

[MIRROR] Tiny HTTP server
https://git.openwrt.org/?p=project/uhttpd.git;
11 stars 7 forks source link

uhttpd accepts requests with multiple `Content-Length` headers, prioritizing the last #8

Open kenballus opened 5 months ago

kenballus commented 5 months ago

From RFC 7230:

If a message is received without Transfer-Encoding and with either multiple Content-Length header fields having differing field-values or a single Content-Length header field having an invalid value, then the message framing is invalid and the recipient MUST treat it as an unrecoverable error. If this is a request message, the server MUST respond with a 400 (Bad Request) status code and then close the connection.

uhttpd does not enforce this rule. Instead, when it receives a request with multiple conflicting Content-Length headers, it prioritizes the last. This behavior doesn't pair nicely with gateway servers that prioritize the first receives Content-Length header, but forward them all as-is.