Are there languages/software that implements http status code 418? [closed]
Asked Answered
W

7

32

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);
Woadwaxen answered 3/6, 2014 at 14:37 Comment(9)
Mine does. It returns 418 if you try to access a feature you haven't unlocked yet, and encourages you to have some tea and relax.Aphasic
Well but it is still a 200 OK there, isn't it?Woadwaxen
If you call the page directly, then sure. Just like if you go to any site's 404 page directly, you'll get a 200 OK of the error document. But if you try to access a feature that you haven't unlocked on my site, it will respond with a "proper" 418 error code.Aphasic
node.js: res.send(418)Steward
@Niet: Nice :-) But it is not actually the server supporting this correct? Meaning: You do put it in the header of the response, and not just set it to a 418, which the server knows by itself, is that right? I mean, it works too, but yeah ^^ (still nice way, to use this)Woadwaxen
Right, it is a manual setting to 418. This is because servers aren't teapots, and therefore cannot correctly implement 418 natively. Now, if one were to have a teapot that could be controlled by HTTP, then you could reasonably implement 418 as an appropriate response to GET /coffee HTCPCP/1.0 or something :pAphasic
I still like that thought a lot ^^Woadwaxen
Well the problem is, that it would have to be @OlegS. 's comment that got the answer to this question. Seems like node.js does support 418 natively and his res.send(418) sends a proper I am a teapot message to go with it! (Which was what I was really looking for) Your answers are great examples none the less, but having server software (apache, nginx, etc.) support this natively is just awesome / what I wanted. Sry for being ambiguous in my question (not a native speaker). But thx for reminding, I will write an answer with that. If Oleg also answers, I will delete mine and accept his!Woadwaxen
@Levit no worries, I am happy to bump your answer upSteward
W
27

Websites that have implemented it

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)

Woadwaxen answered 25/2, 2015 at 7:58 Comment(0)
H
37

Google does it.

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

www.google.com/teapot

Hauler answered 20/11, 2014 at 5:19 Comment(2)
Surely google.com/brewcoffee would be more appropriate for them to use?!Disguise
curl -H "Accept-Additions: Chocolate" -X BREW coffee://google.com/brevilleAuction
W
27

Websites that have implemented it

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)

Woadwaxen answered 25/2, 2015 at 7:58 Comment(0)
B
4

Yes, it is implemented (by a teapot).

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

Bedbug answered 21/11, 2014 at 18:55 Comment(0)
S
4

Python 3.9 will support HTTP 418 from its next (fifth) alpha release. I opened a pull request for this to be supported which was merged last weekend.

Suk answered 16/3, 2020 at 18:41 Comment(0)
B
2

Stack overflow implements it:

https://meta.stackexchange.com/questions/185426/stack-overflow-returning-http-error-code-418-im-a-teapot

albeit, a little creative, when dealing with CSRF violations.

Blasting answered 30/3, 2015 at 9:20 Comment(0)
R
2

Go lang's net/http package codifies HTTP 418 Status as a constant: StatusTeapot.

Reply answered 13/12, 2015 at 4:0 Comment(1)
Awesome! Thanks ... added to the list.Woadwaxen
D
1

My server, www.snarked.org, does it if the pathname begins "/coffee" or "/pot-" followed by a digit, or methods BREW or WHEN, or a scheme equating to "coffee:" (actually, the regex pattern "^[CK][AO]FF?[EIO]E?$" which covers most western-European languages). After 60 seconds, it rolls over to Google's top hit for teapots.

Donatist answered 22/3, 2015 at 23:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.