HTTP Request & Response Service, written in PHP
/ipReturns Request IP./user-agentReturns user-agent./headersReturns the array of request headers./getSend GET data./postSend POST data./patchSend PATCH data./putSend PUT data./deleteSend DELETE data/gzipReturns gzip-encoded data./status/:codeReturns given HTTP Status code./response-headers?key=valReturns given response headers./redirect/:n301 Redirects n times./relative-redirect/:n302 Relative redirects n times./cookiesReturns cookie data./cookies/set?name=valueSets one or more cookies./basic-auth/:user/:passwdChallenges HTTP Basic Auth./downloadPrompts the file download dialog./stream/:nStreams n lines with a 1 second delay between each line./delay/:nDelays responding for n seconds./htmlRenders an HTML Page./robots.txtReturns some robots.txt rules./denyDenied by robots.txt file.
Web service for testing HTTP or cURL based libraries. Or testing your CLI cURL foo.
All endpoint responses are JSON-encoded.
Requires PHP >= 5.3.0
If hosted in a subfolder, modify the define('PATH_SHIFT', 0); constant to the level of subpaths.
=========
Requires PHP >= 5.4.0
php -S localhost:8080 index.php$ curl http://localhost:8080/ip
{
"ip": "::1"
}{
"user-agent": "curl\/7.29.0"
}{
"method": "GET",
"ip": "::1",
"uri": "http:\/\/localhost:8080\/get?k=v",
"path": {
"path": "\/get",
"query": "k=v"
},
"headers": {
"Host": "localhost:8080",
"User-Agent": "Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko\/20100101 Firefox\/20.0",
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Cache-Control": "max-age=0"
},
"get": {
"k": "v"
},
"post": [],
"files": [],
"body": "",
"json": null
}$ curl http://localhost:8080/post?k=v -F somefile=@sample.txt
{
"method": "POST",
"ip": "::1",
"uri": "http:\/\/localhost:8080\/post?k=v",
"path": {
"path": "\/post",
"query": "k=v"
},
"headers": {
"User-Agent": "curl\/7.29.0",
"Host": "localhost:8080",
"Accept": "*\/*",
"Content-Length": "356",
"Expect": "100-continue",
"Content-Type": "multipart\/form-data; boundary=----------------------------9ddcdc88b911"
},
"get": {
"k": "v"
},
"post": [],
"files": {
"somefile": "File content output here...\n"
},
"body": "",
"json": null
}$ curl -X PUT http://localhost:8080/put?k=v -d '{"a":1}'
{
"method": "PUT",
"ip": "::1",
"uri": "http:\/\/localhost:8080\/put?k=v",
"path": {
"path": "\/put",
"query": "k=v"
},
"headers": {
"User-Agent": "curl\/7.29.0",
"Host": "localhost:8080",
"Accept": "*\/*",
"Content-Length": "7",
"Content-Type": "application\/x-www-form-urlencoded"
},
"get": {
"k": "v"
},
"post": [],
"files": [],
"body": "{\"a\":1}",
"json": {
"a": 1
}
}$ curl -I http://localhost:8080/status/201
HTTP/1.1 201 Created
Host: localhost:8080
Connection: close
X-Powered-By: PHP/5.4.11
Content-type: text/html
Based on httpbin by Kenneth Reitz.