-
-
Save SomajitDey/c4479c034d79b594dae1b564d86e69c7 to your computer and use it in GitHub Desktop.
Socat HTTP echo server
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/bash | |
socat -v -T0.05 tcp-l:8081,reuseaddr,fork system:"echo 'HTTP/1.1 200 OK'; echo 'Connection: close'; echo; cat" |
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/bash | |
handle() { | |
echo 'HTTP/1.0 200 OK' | |
echo 'Content-Type: text/plain' | |
echo "Date: $(date)" | |
echo "Server: $SOCAT_SOCKADDR:$SOCAT_SOCKPORT" | |
echo "Client: $SOCAT_PEERADDR:$SOCAT_PEERPORT" | |
echo 'Connection: close' | |
echo | |
cat | |
} | |
case $1 in | |
"bind") | |
socat -T0.05 -v tcp-l:8081,reuseaddr,fork,crlf system:". $0 && handle" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment