Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active June 25, 2024 08:53
Show Gist options
  • Save CMCDragonkai/b7c19f30f9d15691a66da3094f2e597b to your computer and use it in GitHub Desktop.
Save CMCDragonkai/b7c19f30f9d15691a66da3094f2e597b to your computer and use it in GitHub Desktop.
Socat: HTTP Server that Terminates Early (useful for testing downstream service robustness)
#!/usr/bin/env bash
# change the sleep time appropriately
# this server is persistent
# mix and match with Content-Length and having larger and less content then
# is actually produced
# as well as malformed Chunked Encoding
socat \
-v -d -d \
TCP-LISTEN:1234,crlf,reuseaddr,fork \
SYSTEM:"
echo HTTP/1.1 200 OK;
echo Content-Type\: text/plain;
echo;
curl 'http://mirror.internode.on.net/pub/test/1000meg.test' &
sleep 4s && kill %1 && exit 1;
"
# alternatively just use http://pathod.net/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment