Skip to content

Instantly share code, notes, and snippets.

@myun2
Created September 6, 2021 17:24
Show Gist options
  • Save myun2/1fdffab599ea9a7710c4d8b2a719c2d8 to your computer and use it in GitHub Desktop.
Save myun2/1fdffab599ea9a7710c4d8b2a719c2d8 to your computer and use it in GitHub Desktop.
#!/bin/sh
mkfifo .pipe
function res {
echo 'HTTP/1.1 200 OK'
echo "Host: `hostname`"
echo "Date: `date -R`"
echo "Content-Type: text/plain"
echo "Content-Length: 5"
echo ''
echo 'hello'
}
function serv {
read method path version
echo $method $path $version
res > .pipe
while read line; do :; done
}
trap 'rm .pipe; exit' SIGINT
while true; do cat .pipe | nc -l 9898 | serv ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment