Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there languages/software that implements http status code 418?

I know that status code 418 was defined as a April Fools' joke, and "is not expected to be implemented by actual HTTP servers" as is stated on Wikipedia.

But I would be interested if any of you knew of a language/webserver/IDE that supports it.

I was trying on Apache (via php), and obviously it got me an internal error (500). I just like the humor behind it (am not trying to troll here) and would like to know if more than just Emacs implements this.


More precisely: It could be emulated in php for example by doing something like ...

header("HTTP/1.1 418 Whatever text I'd like");

... but do any of you know any actual server software, or language in particular, that implements it natively, where something like the following would not throw a 500, but actually work:

http_response_code(418);
like image 570
Levite Avatar asked Jun 03 '14 14:06

Levite


People also ask

How do I get a 418 status code?

The HTTP 418 I'm a teapot client error response code indicates that the server refuses to brew coffee because it is, permanently, a teapot. A combined coffee/tea pot that is temporarily out of coffee should instead return 503.

Why does 418 exist?

What Is a 418 Status Code? Any attempt to brew coffee with a teapot should result in the error code “418 I'm a teapot”. The resulting entity body MAY be short and stout. This status code is a reference to the Hyper Text Coffee Pot Control Protocol, which was released in 1998 as an April Fools' joke.

Can I use custom HTTP status codes?

Yes, as long as you respect the class -- that is, 2xx for success, 4xx for Client error, etc. So you can return custom 4XX error codes (preferably those that are unassigned) for your own application's error conditions.

How many HTTP status codes are there?

The value of HTTP status codes There are 16 status codes defined in RFC1945 (the HTTP 1.0 specification). These status codes were motivated by pragmatism. Web browsers are generic, in that they can be used to talk to any web server.


3 Answers

Google does it.

Try clicking on the teapot, or tilting your mobile device.

www.google.com/teapot

like image 52
Buttle Butkus Avatar answered Sep 20 '22 11:09

Buttle Butkus


Websites that have implemented it

  • Google - www.google.com/teapot - (Details from @ButtleButkus)
  • Stackoverflow on CSRF violations - Meta question about it - (Details from @ImmortalBlue)
  • A teapot - joereddington.com/projects/418.. - (Details from @MegaTom)
  • Snarked - www.snarked.org/coffee - (Details from @MR.X)

Languages that support it natively

Node.js

res.send(418)

Sends following HTTP header:

HTTP/1.1 418 I'm a teapot
Date: Wed, 25 Feb 2015 07:08:27 GMT
Connection: keep-alive
Transfer-Encoding: chunked

The actual node.js code used to get this response was:

require('http').createServer(function(q,s) {
    s.writeHead(418);
    s.end();
}).listen(80);

Golang

http.Error(w, http.StatusText(418), 418)

Python

Within native libraries, starting from Python 3.9 (Details @Ross)

like image 42
Levite Avatar answered Sep 20 '22 11:09

Levite


Yes, it is implemented (by a teapot).

This error code is an impotent part of HTCPCP(Hyper Text Coffee Pot Control Protocol).

like image 20
MegaTom Avatar answered Sep 20 '22 11:09

MegaTom