An HTTP server in a single .c file
darkhttpd is cool, and it's pretty featureful for a small program, but it's also 2500 lines of code.<p>If you liked it, you might also like my server httpdito: <a href="http://canonical.org/~kragen/sw/dev3/server.s" rel="nofollow">http://canonical.org/~kragen/sw/dev3/server.s</a> which has documentation in <a href="http://canonical.org/~kragen/sw/dev3/httpdito-readme" rel="nofollow">http://canonical.org/~kragen/sw/dev3/httpdito-readme</a>.  It's also an HTTP server in a single source file, but it's i386 assembly, for Linux, that doesn't use libc.  It's only about 700 lines of code, and the executable is up to 2060 <i>bytes</i> now that I've added CSS and PDF support to it.<p>httpdito is, to my surprise, practically useful on occasion as an alternative to things like `python -m SimpleHTTPServer`.<p>Unlike the server in Koshkin's excellent comment <a href="https://news.ycombinator.com/item?id=26672683" rel="nofollow">https://news.ycombinator.com/item?id=26672683</a> httpdito <i>does</i> send CRLFs as the HTTP standard demands.  Unfortunately it also requires them in the request.  Also—and this is a key point on which most software falls down—httpdito's documentation contains a section entitled "Are you insane?", which really is a question every programmer ought to answer in their documentation.<p>It doesn't have most of the things darkhttpd has, though.  It doesn't support IPv6, HEAD, directory listings, byte ranges, conditional requests, keepalive, name-based virtual hosting, sendfile, logging, chroot, or privsep, and doesn't run on Solaris, SPARC, or ARM.  But if you're looking for features like "small memory footprint" and "no installation needed" and "no messing around with config files" it may actually be better than darkhttpd.  Due in large part to improvements in modern Linux and its small memory footprint (normally 5 pages) it's efficient enough to saturate a gigabit connection.