View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Charlie Stross > NetServer-Generic-1.03 > examples/shttpd


Annotate this POD


New  4
Open  1
View/Report Bugs

shttpd -- a trivial HTTP server ^

This is not a real web server, although it might turn into one eventually!

You will need to modify %config (specifically the hostname) before it will do anything useful. You may also need to modify the allowed and forbidden anonymous arrays; these are given to provide an example of simple access control to a server.

shttpd understands a single HTTP command:

  GET I<filename>

It looks for files in $htbase (defined in url_to_file(), the subroutine that maps HTTP requests to absolute pathnames). If a trailing slash is encountered, it appends $htdefault (currently set to index.html).

If the file is not found, it returns a 404: File not found response -- otherwise it assumes the file is HTML and sends it(!). This may not be what you want to do if the file is not HTML, so take care.

shttpd doesn't understand CGI scripts, relative URLs, or just about anything. However, it serves as a skeleton which can easily be extended to add these features.

syntax highlighting: