News for hackers. Stuff that matters.
Re:Show HN: Micro HTTP server in 22 lines of C by pornel on Sunday August 01, 2021 @06:49AM (#28025339)
HTTP/1 is deceptive, because you think "oh, I'll just read RFC 2616, make a state machine, and I'm done!". But then writing a browser-compatible HTTP/1 client is a whole another bag of problems that weren't even documented until recently.

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.

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.