Skip to content

Instantly share code, notes, and snippets.

@supertunaman
Forked from pib/fakeserver.sh
Last active December 12, 2015 04:08
Show Gist options
  • Save supertunaman/4711881 to your computer and use it in GitHub Desktop.
Save supertunaman/4711881 to your computer and use it in GitHub Desktop.
#!/bin/bash
BODY="$1"
if [ -z "$1" ]; then
BODY="/proc/uptime"
fi
{
echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c $BODY | egrep -o '^[0-9]+')\r\nContent-Type: $(file -b --mime-type $BODY)\r\n\r\n"
cat $BODY
} | nc -l 8080 -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment