5 ms·
Httpstat.us: API for generating different HTTP codes.
- kilian 16y agoI like how it implements "418 I'm a teapot" as well :)
- ErrantX 16y agoFrom the click through (http://www.ietf.org/rfc/rfc2324.txt http://www.ietf.org/rfc/rfc2324.txt): 2.1.4 WHEN method When coffee is poured, and milk is offered, it is necessary for the holder of the recipient of milk to say "when" at the time when sufficient milk has been introduced into the coffee. For this purpose, the "WHEN" method has been added to HTCPCP. Enough? Say WHEN.
- JonnieCache 16y agoExcept it doesn't actually, it returns 'Unknown Error.' Disappointed. Maybe varnish isn't allowing it through? $ curl -v http://httpstat.us/418 * About to connect() to httpstat.us port 80 (#0) * Trying 75.101.145.87... connected * Connected to httpstat.us (75.101.145.87) port 80 (#0) > GET /418 HTTP/1.1 > User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3 > Host: httpstat.us > Accept: */* > < HTTP/1.1 418 Unknown Error < Server: nginx/0.7.67 < Date: Tue, 15 Feb 2011 16:46:59 GMT < Content-Type: text/plain < Connection: keep-alive < Access-Control-Allow-Origin: * < Content-Length: 16 < X-Varnish: 1137499688 < Age: 0 < Via: 1.1 varnish < * Connection #0 to host httpstat.us left intact * Closing connection #0 418 I'm a Teapot
- tatham 16y agoYou're still getting a 418 response there, just not the right status description. Varnish is certainly stuffing us up a bit. There's a note about this at the bottom of the page. If I did this again, I wouldn't deploy it to Heroku for this reason.
- petervandijck 16y agoVery nice :) Perhaps add links to other useful testing services on that page?
- kodeninja 16y agoIf you type http://httpstat.us/1000 http://httpstat.us/1000, it returns: 100 Unknown Status
- eelco 16y agoTo be fair, the website says: "If you send any other three digit number that's not in that list, we'll return it too." They seem to simply truncate the number. E.g., http://httpstat.us/39487394587394857349587 http://httpstat.us/39487394587394857349587 returns "394 Unknown status", but http://httpstat.us/200129038123 http://httpstat.us/200129038123 will return "200 OK"
- tatham 16y agoNice catch. Seems we need to improve our regex. In our view, only three digit codes are valid.
- arthurk 16y agoI did a similar experiment a few years ago. It's based on GAE and you can find it here: http://httpstatus.appspot.com/ http://httpstatus.appspot.com/ source code: https://github.com/arthurk/httpstatus https://github.com/arthurk/httpstatus
- tatham 16y agoNice! :) Mostly, we wanted to play with some tech and we came across the domain name httpstat.us which we just thought was cool.
- jrockway 16y agoI never realized how little browsers knew about http. Firefox treats everything like 200, including things like 305. Odd.
- steveklabnik 16y agoThey don't support PUT or DELETE either, which means that people building RESTful APIs have to fudge it. Ugly.
- mccutchen 16y agoRecent-ish WebKit and Firefox browsers do support PUT and DELETE in XHR requests. I'm pretty sure that any IE < 9 does not, not sure about IE 9 or Opera (though I'd guess Opera does support those verbs).
- stanleydrew 16y agoCounterexample: 401 pops up an authentication dialog.
- tatham 16y agoThe 300 series is not well supported. Most people don't even know that 307 exists - they always use 302.
- eelco 16y agoI wonder where they used CouchDB and Cloudant for (listed at the bottom of the page).
- cytzol 16y agoI was intrigued by all the linked technologies, too. I've spent a day or so writing a site that I can't imagine being more than a few static pages, and it's just running on nginx on this VPS I bought. I can understand monitoring for a site that -has- to be up (otherwise testing suites would start to break), but not the cloud database, let alone programmable markup or managed hosting (Heroku). Surely all that extra complexity is going to cost more in downtime than the time taken to set things up manually?
- mlmilleratmit 16y agoWhile we're honored to see that Cloudant plays a roll in the their app, I imagine the real answer to your question is the phrase "Experiment" at the bottom of the page. I imagine this is about learning/testing, not the most optimized way to skin the cat.
- tatham 16y agoYou're correct - it was all one big experiment so we threw way more technologies at it than we had to. http://isitbeerti.me http://isitbeerti.me was another experiment of ours on the .NET platform
- tatham 16y agoHeroku was a lot simpler than us spinning up (or paying for) a VPS. The other technologies were mostly just for fun.
- ashishb4u 16y agohttp://httpstat.us/404 http://httpstat.us/404 seems to dump HTML on my browser.
- atuladhar 16y agoYeah; it's sending back text/plain... http://httpstat.us/404 http://httpstat.us/404 HTTP/1.1 404 Not Found Server: nginx/0.7.67 Date: Tue, 15 Feb 2011 14:13:09 GMT Content-Type: text/plain Access-Control-Allow-Origin: * X-Varnish: 651017685 Age: 0 Via: 1.1 varnish Transfer-Encoding: chunked Proxy-Connection: Keep-Alive Connection: Keep-Alive Content-Encoding: gzip
- awulf 16y agoVery useful, thanks! A nice addition would be random option like http://httpstat.us/random http://httpstat.us/random or even http://httpstat.us/?random=200+404 http://httpstat.us/?random=200+404.
- slace 16y agoThat is a pretty neat idea, I'm looking into it now. --@slace (co-author of httpstat.us)
- stdbrouw 16y agoAlso interesting, if you're developing an API: http://blog.programmableweb.com/2010/08/16/writing-bulletproof-apps-with-api-errorpoints/ http://blog.programmableweb.com/2010/08/16/writing-bulletpro...
- deleted 16y ago[deleted]
- elliottcarlson 16y ago18 lines of node.js to accomplish something similar - I use something similar as a function in my node.js scripts to be able to send a generic error template based on the code that I pass back to the function. var http = require('http'); http.createServer(function (request, response) { var statusCode = request.url.substr(1, 3); response.writeHead(statusCode, { 'connection' : 'close', 'content-type' : 'text/html' }); response.write('<html>'); response.write('<head><title>' + statusCode + ' ' + http.STATUS_CODES[statusCode] + '</title></head>'); response.write('<body bgcolor="white">'); response.write('<center><h1>' + statusCode + ' ' + http.STATUS_CODES[statusCode] + '</h1></center>'); response.write(' '.repeat(512)); response.write('</body>'); response.end('</html>'); }).listen(8124, "0.0.0.0"); String.prototype.repeat = function(num) { return new Array(num++).join(this); }
- jsdalton 16y agoHere's a little something similar I whipped up using Flask (Python): import time from flask import Flask, make_response, request app = Flask(__name__) @app.route('/<int:status_code>') def return_status(status_code): response = make_response() response.status_code = status_code response.data = response.status sleep = request.args.get('sleep', None) if sleep is not None: time.sleep(int(sleep)) return response if __name__ == '__main__': app.run(debug=True) With a handy little feature, a "sleep" query string param that'll delay the response for the given number of seconds, which I've used to test how a client handles latency etc. [BTW, looks like you're the Elliot Carlson I used to work with way back when. Hope life is treating you well these days! :)]
- elliottcarlson 16y agoHah, indeed! Email me some time - x at sublim dot nl
- tatham 16y agoThis will get you 80% of the way there, but some status codes require certain response headers too. We return these too.
- jonursenbach 16y agoOn the subject of HTTP status codes, I wrote this a week or so ago because I was always sick of having to look up status code definitions. https://github.com/jonursenbach/http-status-code-definitions https://github.com/jonursenbach/http-status-code-definitions
- frytaz 16y agohttp://httpstat.us/000 http://httpstat.us/000 shows Heroku Error Oops, we seem to have a glitch in our system. We've been notified; you might try reloading the page in a little while. v 26026 2077752888
- KishoreKumar 16y agoKindly, can any one tell me why would we need such a website?