Re:Show HN: Micro HTTP server in 22 lines of C
by cookiengineer on Monday August 02, 2021 @01:33AM
(#28033224)
^ This.
Multiple responses, especially with chunked encodings, are really really hard to get right. Even more so when you have to be able to resume downloads due to socket instability.
For example, Content-Length isn't just a single header with an integer, like the spec says. You need to support responses with multiple Content-Length headers and comma-separated lists of potentially contradictory lengths, and then perform garbage error-recovery the way Internet Explorer or Chrome did. Getting this wrong will make your client hang, consume garbage, or allow response stuffing.
https://github.com/web-platform-tests/wpt/pull/10548/files
This problem does not exist in HTTP/2.