Created
February 7, 2011 14:15
-
-
Save drench/814411 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
proxyhost=localhost | |
read method file http | |
if [ "$method" != "GET" ]; then | |
printf "HTTP/1.0 405 Method Not Allowed\r\n" | |
printf "Content-type: text/plain\r\n" | |
printf "Connection: close\r\n\r\nMethod Not Allowed\r\n" | |
exit 111 | |
fi | |
if [ -d "$file" ]; then | |
printf "HTTP/1.0 403 Forbidden\r\n" | |
printf "Content-type: text/plain\r\n" | |
printf "Connection: close\r\n\r\nForbidden\r\n" | |
exit 111 | |
fi | |
if [ -r "$file" ]; then | |
printf "HTTP/1.0 200 OK\r\n" | |
printf "Content-type: text/plain\r\n\r\n" | |
cat $file | |
else | |
printf "$method $file HTTP/1.0\r\nHost: $proxyhost\r\n\r\n" | | |
nc $proxyhost 80 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment