
Whatever you set the URL to, that HTTP code will be returned - ca98am79
http://codes.io/
======
techthumb
Similar to [http://httpbin.org/](http://httpbin.org/) &
[http://httpbin.org/status/](http://httpbin.org/status/)

~~~
petke
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.

~~~
jjuhl
You could have just looked at the traffic directly with wireshark rather than
trust an external site.

~~~
nchelluri
I think this might not be possible for SSL/TLS traffic, without some kind of
MITM.

~~~
lisivka
It is possible with SSL/TLS traffice: you need to supply private key to
WireShark, so it will be able to decode conversation.

------
kseistrup
Neat idea.

Please support “451 Unavailable for legal reasons”.

[http://www.451unavailable.org/](http://www.451unavailable.org/)

[https://en.wikipedia.org/wiki/HTTP_451](https://en.wikipedia.org/wiki/HTTP_451)

~~~
TheAndruu
My favorite is 418 - I'm a teapot:
[https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_...](https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol)

------
mansilladev
On another note, if you want a swell compilation and explanation of every HTTP
status code:

[https://httpstatuses.com/](https://httpstatuses.com/)

or by individual code..

[https://httpstatuses.com/200](https://httpstatuses.com/200)
[https://httpstatuses.com/201](https://httpstatuses.com/201)
[https://httpstatuses.com/404](https://httpstatuses.com/404)
[https://httpstatuses.com/418](https://httpstatuses.com/418)

------
jschulenklopper
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/](http://httpbin.org/),
[https://httpstatuses.com/](https://httpstatuses.com/),
[http://httpstat.us/](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](http://example.com/404) I request
[http://example.com/resource/id?response=404](http://example.com/resource/id?response=404)
to get a 404 response. [http://example.com/resource/another-
id?response=200](http://example.com/resource/another-id?response=200) gets a
200 code.

~~~
jschulenklopper
Oh, and also other request types are specified in the URL query, such as a
delayed response:
[http://example.com/resource/id?delay=0.5](http://example.com/resource/id?delay=0.5),
which returns a 200 after 0.5 seconds.

In this way, combining requested responses is also possible:
[http://example.com/resource/id?status=500&delay=2](http://example.com/resource/id?status=500&delay=2)
to return a 500 after 2 seconds.

I couldn't figure out if this behavior is also possible with services
specifying the desired responses in the URL path.

------
1337p337
Unfortunately it just returns the code, not a compliant response (e.g., 405
should return an Allow: header).

------
ymse
This is my go-to resource for looking up status codes:
[https://http.cat/](https://http.cat/)

Examples: [https://http.cat/418](https://http.cat/418) \-
[https://http.cat/451](https://http.cat/451)

------
bodhi
Similar: [http://httpstat.us](http://httpstat.us)

------
Gnarl
Input validation needed. [http://codes.io/12345](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."

------
shizcakes
Here's one you can run yourself, if you want:
[https://github.com/bmhatfield/httpecho](https://github.com/bmhatfield/httpecho)

~~~
SnootyMonkey
[http://posthere.io/](http://posthere.io/) is also OSS and you can run it
yourself if you want.

------
iam4xzor
[http://stackoverflow.com/questions/10046972/msie-returns-
sta...](http://stackoverflow.com/questions/10046972/msie-returns-status-code-
of-1223-for-ajax-request)

[http://codes.io/1223](http://codes.io/1223) -> 503

~~~
delinka
Anything unexpected returns 503. Try
[http://codes.io/404/](http://codes.io/404/) (notice the ending /)

Besides, 1223 isn't specified by the HTTP RFCs, nor is it returned anywhere
except from a library call in a buggy library. I'd say it's not appropriate
for an HTTP testing service to support 1223.

------
phyzome
For local testing I often run pathod
([http://pathod.net/](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.

------
rand7773
Weird, it doesn't implement "HTTP 451 Unavailable For Legal Reasons" or "HTTP
420 DAB Session". It also doesn't return an Allow: header for 405. It also
doesn't return 100-103.

~~~
SnootyMonkey
[https://posthere.io/](https://posthere.io/) implements 451, 420 and 100-103.
It also doesn't return an Allow: header for 405.

I opened an issue for that:
[https://github.com/SnootyMonkey/posthere.io/issues/4](https://github.com/SnootyMonkey/posthere.io/issues/4)

~~~
rand7773
Awesome!

------
72deluxe
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](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)

~~~
jschulenklopper
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](http://codes.io/304). This will return
a `304 Not Modified` response, which can be helpful in writing testcode for
your API service.

------
_RPM
Interesting. I noticed it is built on Heroku platform. What specific stack did
you use to implement this?

~~~
joevandyk
you could use pretty much anything.

rails would be

    
    
        def status
          render(text: params[:status], status: params[:status])
        end

~~~
nchelluri
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 :)

------
jumby
100 doesn't work (it returns 503)

~~~
delinka
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.

------
maytc
Similar [http://get.reststat.us/407](http://get.reststat.us/407)

------
ars
Can you print the text in the body of the result? Not just the code.

------
nvahalik
418 Works...

~~~
conradk
So? It's valid, isn't it? "I'm a teapot"?

------
__michaelg
Huh?

$ curl -i codes.io/600

HTTP/1.1 -424 ???

...

------
voynich61
We have reached peak HN.

