News for hackers. Stuff that matters.
Re:Show HN: Micro HTTP server in 22 lines of C by hdjjhhvvhga on Saturday July 31, 2021 @11:49AM (#28019169)
The fact that someone wrote a parser that's hard to follow doesn't mean that parsing HTTP/1.x is extremely difficult. What is really hard is to construct a parser that is at the same time (1) fast, (2) complete, (3) secure. It is much easier to choose just two, compare e.g. the one based on Nginx[0] vs picohttpparser [1].

[0] https://github.com/Samsung/http-parser/blob/master/http_pars...

[1] https://github.com/h2o/picohttpparser/blob/master/picohttppa...

Re:Show HN: Micro HTTP server in 22 lines of C by a-dub on Saturday July 31, 2021 @12:44PM (#28019693)
for the basics, however http/1.x is pretty simple. you can test webserver health by literally typing in the request.

i suspect the complexity you speak of is similar to MIME. where SMTP/POP/IMAP are pretty simple, things got pretty hairy with the introduction of MIME, SASL and friends.

i think, though, that most of the complicated stuff in http is optional, is it not? like if you don't send a header that compression is supported, the server won't compress... or am I misremembering?

either way, simpler to understand from a packet capture than a grpc stream or spdy/http2 stream.

Re:Show HN: Micro HTTP server in 22 lines of C by jart on Saturday July 31, 2021 @03:04PM (#28020761)
Pretty much everything is optional if you stick to http/1.0. If you implement http/1.1 then you're required to do a lot of non-essential stuff like chunk encoding, pipelining, and provisionals which themselves are reasonably trivial too but they make the server code less elegant. If you want a protocol that's actually hard, implement SIP.
Re:Show HN: Micro HTTP server in 22 lines of C by jsjohnst on Saturday July 31, 2021 @02:29PM (#28020519)
I once heard that it’s impossible to build a “spec compliant” IMAP4 library as the spec itself is contradictory. Don’t have a reference to prove it, so I could be wrong.