mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-08-12 05:11:24 +00:00
RFC 9110 5.3 lets a coding list be split across several Transfer-Encoding lines, which combine, in the order the lines were received, into one comma-separated list. RFC 9112 6.1 then frames the message as chunked only when chunked is the final coding of that combined list. is_chunked_transfer_encoding() could not apply that rule while Headers was an unordered_multimap, since the order of the lines was not recoverable, so it fell back to reporting any message naming chunked on any line as chunked. Headers now preserves the order the lines were received in, so read the final coding directly: the last token of the last line. The fallback erred toward reporting chunked because mis-reading a chunked message as unframed leaves its body in the socket, where a keep-alive connection parses it as a smuggled request. That direction is no longer needed. A request whose combined list ends in something other than chunked is now reported as not chunked, and process_request() answers 400 and closes rather than letting it reach the "no body" path, which is what it already did for the single-line "chunked, gzip" form. So `Transfer-Encoding: chunked` followed by `Transfer-Encoding: gzip` is rejected instead of being read as chunked, and `gzip` followed by `chunked` is still accepted. A trailing line carrying no coding at all now leaves the combined list ending in nothing rather than inheriting the coding from the line before it.