Advanced Code Golf - Write a small HTTP server Your challenge is to write a code-golf HTTP server that accepts GET requests. It obviously doesn't have to be fully featured, but it must serve files from a directory.

Rules:


The HTTP server must listen on TCP port 36895 (0x901F)
It must serve files from /var/www on *NIX systems (e.g. Linux), or C:\hgolf on Windows.
You may ignore all incoming HTTP headers except the GET itself.
If the HTTP method is not GET, you must send back a status code of "405 Not Supported" and a body of "405 Not Supported".
If the file does not exist, you must send back a status code of "404 File Not Found" and a body of "404 File Not Found".
If the file exists but could not be read for some reason, you must send back a status code of "500 Server Error" and a body of "500 Server Error".
If the user requests / or any other existing directory root (e.g. /foo/ where a directory foo exists in /var/www/), respond with a blank page.
Your response must contain at least the minimum headers to allow the content to be displayed on Firefox 8.0 and Internet Explorer 8.0
You must respond with the Content-Type header set, but you only have to support extensions html =&gt; text/html and txt =&gt; text/plain. For any other file extension, Send application/octet-stream as the content type.
Your code must be able to transfer both ASCII and binary data, though you do not explicitly have to distinguish between the two.
You may not use 3rd party libraries.
You may not use in-built classes or features designed to process HTTP requests (e.g. HttpListener in C#)
If your code will only work on a specific OS due to the socket APIs you've used, please state this.


Solutions must include an image showing it serving a HTML page to a browser.

If you've got any questions, please feel free to ask! :)
Bash+netcat: 354 characters

Two script files are used.
No URL decoding, thus file names with spaces and special characters not supported.
Single threaded, so concurrent requests may fail.
Tested on Linux, works nicely with Firefox and Opera.

webserver.sh (33 characters):
while :;do nc -lp36895 -e./w;done

w (321 characters):
read m p v
p=/var/www$p
t=text/plain
[[ -r $p ]]||s='500 Server Error'
[[ -e $p ]]||s='404 Not Found'
[[ $m != GET ]]&amp;&amp;s='405 Not Supported'
[[ $s||-d $p ]]||case ${p##*.} in
txt);;html)t=text/html;;*)t=application/octet-stream;;esac
echo &quot;$v ${s-200 Ok}
Content-Type:$t
&quot;
[[ $s ]]&amp;&amp;echo $s||{ [[ -d $p ]]&amp;&amp;echo||cat $p;}

Sample run:
bash-4.2$ ./webserver.sh 

Sample visit (Firefox 19.0):