I’ve been writing an HTTP server lately and man its hard. Oh sure writing some piece of crap that will parse some request text is fairly easy. Writing a system that manages its own memory and can (hopefully) handle thousands of requests per second without slowing down is no easy task.
I’ve reimplemented the same thing 3 times now, starting in C++, then moving to C. My 3rd implementation is actually very similar to my first implementation. Its also similar to nginx because we both use buffer chains. I didn’t discover nginx until partway through the third rewrite. I’ve also discovered GWAN, but its source code is closed so I can only get tidbits about how it works from its FAQ and forum posts. I’ve looked at the source for nginx and that thing is convoluted and dense.
My goals for this server are for the source code to be *easy* to read. Nice long and descriptive variable names plugged into descriptive function names makes the code almost self documenting (HA!). The parse is pretty complicated though, at least at first glance.
Anyway, I’ve also looked at Mongrel2 which is a pretty cool concept. Or maybe the website just fooled me.
I would like to write here about how the implementation is going, but I will probably spend far more time actually coding and testing rather than writing. We’ll see.