News for hackers. Stuff that matters.
Re:Show HN: Micro HTTP server in 22 lines of C by ysleepy on Saturday July 31, 2021 @03:42PM (#28021005)
I consider Header value parsing and URL parsing part of HTTP, those are certainly not trivial.

The charset problems alone are a nightmare.

Parsing the wire format is pretty breezy, (Don't forget trailers!)

Re:Show HN: Micro HTTP server in 22 lines of C by jart on Saturday July 31, 2021 @03:52PM (#28021073)
Trailers can be parsed by invoking the function using something along the lines of ParseHttpMessage((struct HttpMessage){.t = kHttpStateName}, p, n) where you just tell the parser to skip the first-line states. Charset isn't a nightmare either. Headers are ISO-8601-1 so you just say {0300 | c >> 6, 0200 | c & 077} to turn them into UTF-8. It's not difficult. It might be if you want to support MIME. But this is HTTP we're talking about. It was made to be simple! We're talking Internet engineering on the lowest difficulty setting. Implement a TCP or SIP stack if you want hard.
Re:Show HN: Micro HTTP server in 22 lines of C by cormacrelf on Saturday July 31, 2021 @11:47PM (#28023637)
I think ysleepy might be referring to HTML charsets, which can be set in the HTTP header. They are a nightmare, I have come across HTML documents with so many “if lt IE 9” comments that they move the charset declaration out of the first 1000 bytes, causing browsers to ignore it and interpret as Latin 1. But yes, not actually anything to do with parsing HTTP.