Last Updated: February 25, 2016
·
1.263K
· timusg

one liner accept all http server

netcat is swiss-army knife for TCP/IP, following command creates a http server, which can accept all requests with any http verb or paths and return 200 OK.

while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo foo; } | nc -l 80; done

testing:

curl -XPOST http://127.0.0.1/foo/bar

helpful for stubbing external http service in need.