[RndTbl] Simple HTTP server.

Sean Cody sean at franticfilms.com
Tue Jul 25 12:19:12 CDT 2006

The HTTP protocol is so ridiculously simple yet usually implemented  
in a convoluted and complicated way (ie. Apache, IIS).

If you ever wondered how a web server works but didn't care to read  
the spec (RFC1945) take a look at this 'simple' implementation in Perl.,
This is a basic web server, written as the basis for a component in  
an embedded project I'm working on.
I've since decided to re-implement it in C (perl + chroot = annoying)  
but the perl version would be a decent instructional tool.


I've implemented the bare minimum you need to make a web server.
The bare minimum needed is:
	GET		<-- Standard 'grab me a document' or CGI with appending key/ 
values to the URL.
	POST  		<-- CGI without appending to URL

For the hell of it... MIME types and Cookie support are also in there  
but only because they were easy.

Just so it works 'out of the box,' I've included a simple site which  
tests most of the functionality (save for cookies, I know it works  
but too lazy to write a test case).

Contents of the Tarball:
www/www.pl <-- Web server... runs on port 8080 by default but open it  
up and take a gander.
www/site/environment.cgi <-- sh shell script...spits out the current  
environment variables, ie CGI  not in Perl
www/site/cgi_test.cgi <-- Perl script, simple GET/POST handling.
www/site/index.html <-- simple web page
www/site/gibson_for_dummies.jpg <-- included in simple web page and  
proves MIME types are working.

The only use for this thing is if you really wanted to know how a web  
server worked and didn't want the pain of dealing with the RFC or the  
Apache source.
I've tried to keep the code as clean and clear as possible (I know at  
least one other person that could read and understand it).

If you find the damned thing useful then feel free to use it however  
you want.


More information about the Roundtable mailing list