shttpd - a simple web server


[chris@vlc chris]$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / 1.0

HTTP/1.0 200 OK
MIME-version: 1.0
Content-type:text/html
Content-length:96

<html>
<head>
<title>document title</title>
</head>
<body>
<p>document body</p>
</body>
</html>
Connection closed by foreign host.
[chris@vlc chris]$ 

Apache is a little like using a sledgehammer to crack a walnut when it comes to most websites. As a consequence I wrote shttpd, which supports just the bare basics - HTTP 1.0 and CGI 1.1. In other words,it will serve static webpages and CGI queries (both the GET and POST varieties). The only plush add-ons are an optional directory listing feature, and the ability to lookup hosts for logging purposes. Configuration is a simple matter of editing config.h and the Makefile.

There shouldn't be any memory leaks, as the main process does little dynamic memory allocation. There shouldn't be any buffer overflows either, as I've been very pedantic about checking string lengths. I wouldn't recommend it for a production website though, something like thttpd would be a better bet.