Created
August 28, 2014 13:27
-
-
Save ooharak/807363e3d28b953fde16 to your computer and use it in GitHub Desktop.
usage: ./ashttp.sh 'text/html;charset=utf-8' < index.html | nc -l 8080
This file contains 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 | |
if [ $# -eq 0 ]; then | |
mime='text/plain;charset=utf-8' | |
else | |
mime="$1" | |
fi | |
CR=$'\x0d' | |
cat <<EOF | sed -e "s/\$/$CR/g" | |
HTTP/1.0 200 OK | |
Content-Type: $mime | |
EOF | |
cat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A toy HTTP Server