Skip to content

Instantly share code, notes, and snippets.

@ynadji
Created October 30, 2012 17:31
Show Gist options
  • Save ynadji/3981722 to your computer and use it in GitHub Desktop.
Save ynadji/3981722 to your computer and use it in GitHub Desktop.
http_download () {
if [ `uname` = "Darwin" ]
then
(
/usr/local/bin/gecho "HTTP/1.0 200 Ok"
/usr/local/bin/gecho "Content-type: `file -bi $1 | tr -d '\n'`"
/usr/local/bin/gecho "Content-Disposition: attachment; filename=$1"
/usr/local/bin/gecho
/usr/local/bin/gcat $1
) | nc -l -p $2
else
(
/usr/local/bin/gecho "HTTP/1.0 200 Ok"
/usr/local/bin/gecho "Content-type: `file -bi $1 | tr -d '\n'`"
/usr/local/bin/gecho "Content-Disposition: attachment; filename=$1"
/usr/local/bin/gecho
/usr/local/bin/gcat $1
) | nc -q 5 -l $2
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment