Skip to content

Instantly share code, notes, and snippets.

@drench
Created February 7, 2011 14:15
Show Gist options
  • Save drench/814411 to your computer and use it in GitHub Desktop.
Save drench/814411 to your computer and use it in GitHub Desktop.
#!/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