Yet More Shelob Hacking

http programming

I’ve been fixing some on my web server again, for fun. Last weekend, I refactored a lot of code, added dynamic mime typing and CGI support! I was going to continue fleshing it out today, but I had to do even more refactoring to clean up some messy code paths. I broke the Http:sendFile() method into several new ones and moved HTTP/1.1 keep-alive handling into a more central location instead of just tacked on to the first place that it worked. One thing that is driving me slightly insane, is that there appears to be a tiny memory leak. I can’t figure out where it is happening since I eliminated almost all dynamic allocations in the stack. As I wrote that sentence, I think I figured out where it could be coming from, but I’ll need to rewrite some more code to fix it. It is so small, you don’t start to notice it until you get at least 1,000 requests. Overall, I’m happy with the design so far. This is my first C--- program and my first serious “server” program. I didn’t do any real upfront design except for drawing on past experience and my gut. I’ve added a number of features and it has been extendable. OOP purists would probably frown on it, but I’m using the subset of C--- and OOP in general that makes sense to me and is practical for what I’m doing. Is there a cleaner way? Likely shrug. I’m getting to the point where a couple of patterns probably make sense. This program is growing organically, but under a tight enough constraint that it isn’t turning into a mess (at least not yet). The other thing that starts making sense is Unit Testing. I’ve been doing more refactoring than I have been adding new features and it would be awesome to be able to run a test suite and know that I haven’t broken anything. I’m not even really sure where to begin on that, but it is obvious that Shelob is becoming more of a “real” program and less of a toy. A couple more good weekends and it would actually be semi-useful.