Development HTTP and HTTPS servers to echo (and drop) incoming requests
- Install
openssl
andpython 3
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt -subj '/CN=localhost'
- Trust it (OS X)
sudo security add-trusted-cert -p ssl -d -r trustRoot -k ~/Library/Keychains/login.keychain localhost.crt
HTTP - port 8080
$ python echoserver_http.py
Listening on port 8080...
HTTPS - port 8443
$ python echoserver_https.py
Listening on port 8443...
CURL:
curl 'https://localhost:8443/test' -X POST -H 'My-Header: Testing'
curl 'http://localhost:8443/test' -X POST -H 'My-Header: Testing'
HTTPS:
❯ python echoserver_https.py
Listening on port 8443...
HTTPServerRequest(protocol='https', host='localhost:8443', method='POST', uri='/test', version='HTTP/1.1', remote_ip='::1', headers={'My-Header': 'Testing', 'Host': 'localhost:8443', 'Accept': '*/*', 'User-Agent': 'curl/7.43.0'})
HTTP:
❯ python echoserver_http.py
Listening on port 8080...
HTTPServerRequest(protocol='http', host='localhost:8080', method='POST', uri='/test', version='HTTP/1.1', remote_ip='::1', headers={'My-Header': 'Testing', 'Host': 'localhost:8080', 'Accept': '*/*', 'User-Agent': 'curl/7.43.0'})