Neat! I wrote a similar project for Drupal once - https://www.drupal.org/project/generate_errors - I found it to be a good way to learn about HTTP status codes and their meanings. Currently, you've got a finite list of HTTP status codes and don't have definitions. You may want to consider grouping them and including labels. Or don't, I'm just some guy on the internet :-)
I've used https://httpstat.us/ which seems to offer the same features plus configurable delay, although when you hit it 3,000 times a second it doesn't necessarily respond with the code you ask for.
I think the proper term is "status code". Simply using the word "status" by itself is ambiguous and misleading. So any new entrants to this space could choose from a lot of domain suffixes: status.codes, statusco.de, statuscode.info, etc...
I built something similar about a year ago experimenting with AWS's API Gateway. https://mock.codes/ The landing page is an S3 file, and everything is just API Gateway configs.
There used to be a similar service hosted on the same domain that eventually went dead. I bought the domain and brought up this service again. It barely gets used (haven't checked usage in a while) but I've already paid for the domain and it costs me pennies to keep it up and running.
Arbitrary status codes from your webserver is extremely useful for testing your nginx or other reverse-proxy configuration. If your webserver is returning 500s, does nginx retry in an infinite loop? Not good!
Better: if a query causes your webserver to crash, does nginx crash ALL of them while retrying that bad query? :-)
> status.icu will return whatever https status code you want! Use a GET request to any status.icu path to guarantee an HTTP status code.
$ curl -I https://status.icu/418/
HTTP/1.1 500 Internal Server Error
The Nginx configuration responsible for the service[1] just hardcodes a handful of common HTTP status codes. A Go version that supports any status code takes fewer lines than status.icu's nginx.conf, even after gofmt.[2] Not that I think anyone should be relying on a third-party service for "writing browser integration tests" OR "mocking API responses".
furthermore I have never used Go or Ruby, but I could easily read and understand the Go code, I have zero idea what the Runy code is doing, or why they do this [-3, 3] seemingly multi dimensional negative array access
Since it's a static website, with a little effort you can have it cost virtually nothing (less than the domain, probably). S3 and Route53 can go a long way.
46 comments
[ 3.7 ms ] story [ 108 ms ] threadCool project!
There used to be a similar service hosted on the same domain that eventually went dead. I bought the domain and brought up this service again. It barely gets used (haven't checked usage in a while) but I've already paid for the domain and it costs me pennies to keep it up and running.
http://httpbin.org/#/Status_codes
(Response code 418.)
Better: if a query causes your webserver to crash, does nginx crash ALL of them while retrying that bad query? :-)
[1] https://gist.github.com/geetotes/0ddc96f95eecab4e8aa8dd53bcc...
[2] https://gist.github.com/wwalexander/febbc1ba76c8eafa9f94f5cb...
[1] https://gist.github.com/joshmn/66f715c65bc19784f95a0e2ce3c9d...
Most "one liners" fall under the category "most people would format very differently"
And this one at only 140 chars (a classic tweet)
https://httpbin.org/
What I am getting at is that you can't form a url that will do this, you need to interact with the page to trigger it.
Unless you mean "what guarantees do I have that if I integrate this in my workflow it won't be gone tomorrow?". In which case, I agree.
This will be useful to make sure my script works correctly!