Created
September 6, 2021 17:24
-
-
Save myun2/1fdffab599ea9a7710c4d8b2a719c2d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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