I was just going to write a simple script to serve as a HTTP server to return me same response as the offending HTTP server but hey, I thought, there must be an easier way.
So I just obtained raw response from original server, put it into a file and asked netcat to listen and give it back on request.
## on another console
$ cat > response.raw << "EOF" HTTP/1.1 200 OK Accept-Ranges: bytes Content-Length: 36 Content-Type: text/html; charset=utf-8 Last-Modified: Mon, 11 Apr 2016 05:39:53 GMT Server: Caddy Date: Tue, 10 May 2016 08:10:17 GMT Set-Cookie: OPENSHIFT_x7xn3_service-unsecure_SERVERID=c72192d7fe9c33d8dec083448dd4f40f; path=/; HttpOnly Cache-control: private Hello-OpenShift-Path-Test http-8080 EOF $ nc -l 8080 <response.raw
$ curl -v localhost:8080
That's the simplest I could get. It will return the same thing regardless of path and query string you put in your client URL. e.g. this will work the same:
$ curl -v localhost:8080/path&asd=5
Now if you want your server to return something multiple times, then you can try
$ nc -kl 8080 -c 'catresponse.raw'
Another option if your system lacks netcat is the `socat` utility.
$ socat TCP-LISTEN:8080,fork EXEC:"cat response.raw"
If you remove `fork` from the options, it will exit after first connection served. But we can also listen over HTTPS:
$ socat OPENSSL-LISTEN:8080,cert=/path/cert.pem,verify=0 EXEC:"cat response.raw"
Again, add `fork` option to keep listening. This above will ignore client certificate. In fact you can create proper client cert and configure SSL verify. But that's beyond today's topic. FYI, use `socat` version 126.96.36.199+, otherwise you'd be hit with weak DH key used . As a workaround you could generate DH key in a file and provide it with the `dhparams` option to socat.