46 comments

[ 4.3 ms ] story [ 88.1 ms ] thread
Thanks for that. Did not know this existed.
Can second that, httpbin is a great resource!
This site was very helpful when I refractored a program from using libcurl to cpprest. I used it to make sure the sent http request headers where exactly the same.
You could have just looked at the traffic directly with wireshark rather than trust an external site.
I think this might not be possible for SSL/TLS traffic, without some kind of MITM.
It is possible with SSL/TLS traffice: you need to supply private key to WireShark, so it will be able to decode conversation.
Most dev 'MITM' proxy tools have a way to inspect HTTPS by creating a new key and adding it to your systems trust.

Charles has a fairly neat way of making it all work.

I'll remember that next time. I been using fiddler to see websites http traffic which is helpful. But my programs http traffic doesn't show up there.. So ill try wireshark next time.
100 doesn't work (it returns 503)
Seems none of the 1xx series are expected by the service. Anything unexpected returns 503. Try adding a / at the end of one that does work.
(comment deleted)
Interesting. I noticed it is built on Heroku platform. What specific stack did you use to implement this?
you could use pretty much anything.

rails would be

    def status
      render(text: params[:status], status: params[:status])
    end
interestingly, i believe your sample code would, in all but the latest version of Rails, leave someone open to some of the Rails CVEs that just got announced yesterday :)
(comment deleted)
Can you print the text in the body of the result? Not just the code.
Unfortunately it just returns the code, not a compliant response (e.g., 405 should return an Allow: header).
For local testing I often run pathod (http://pathod.net/), which can not only yield arbitrary response codes based on the request URL, but randomly generated headers and body and even timeouts.
Interesting, seems like the upcoming "Hello World" for API services :-)

I also made a "return the HTTP code you request"-service like this, but with another design choice than in this one and some others like http://httpbin.org/, https://httpstatuses.com/, http://httpstat.us/.

Instead of specifying the requested HTTP code in the URL path, I put the requested HTTP code in the URL query, basically ignoring the URL path. In that way, the URL path -- the resource identification in a REST-styled API -- can stay whatever you want as you're specifying the requested status code as query parameter. This made testing a program that uses resources in a REST API easier, as I don't need to rewrite the URL path, but just require to add a query parameter in my test code.

Example: instead of http://example.com/404 I request http://example.com/resource/id?response=404 to get a 404 response. http://example.com/resource/another-id?response=200 gets a 200 code.

Not sure if I'm missing the purpose of this site, but why not just print off this list and refer to it when writing code: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
While that list is handy for sure, the OP's site also enables you to actually get the HTTP status code of your desires, since you can specify it in the request URL path: http://codes.io/304. This will return a `304 Not Modified` response, which can be helpful in writing testcode for your API service.
Input validation needed. http://codes.io/12345 returns " Application Error

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details."

Huh?

$ curl -i codes.io/600

HTTP/1.1 -424 ???

...