是否有语言/软件实现http状态代码418? [英] Are there languages/software that implements http status code 418?
问题描述
我知道状态代码418被定义为愚人节的笑话,预计不会由实际的HTTP服务器实现,如维基百科。
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.
但如果你们中的任何一个人知道,我会感兴趣支持它的语言/网络服务器/ IDE。
But I would be interested if any of you knew of a language/webserver/IDE that supports it.
我正在尝试使用Apache(通过php),显然它给我一个内部错误(500)。我只是喜欢它背后的幽默(我不想在这里试图)并且想知道是否不只是Emacs实现了这一点。
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.
更确切地说:它可以在php中模拟,例如通过做类似的事情......
More precisely: It could be emulated in php for example by doing something like ...
header("HTTP/1.1 418 Whatever text I'd like");
...但你们中的任何人都知道任何实际的服务器软件(或语言)本地实现它,类似下面这样的东西不会抛出500,但实际上有效:
... but do any of you know any actual server software (or language) that implements it natively, where something like the following would not throw a 500, but actually work:
http_response_code(418);
推荐答案
本地支持它的语言
node.js
Languages that support it natively
node.js
res.send(418)
发送以下HTTP标头:
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
用于获得此响应的实际node.js代码为:
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
Golang
http.Error(w, http.StatusText(418), 418)
网站实施了它
- 谷歌 - www.google.com/teapot - (来自@ButtleButkus的详细信息)
- 违反CSRF的Stackoverflow - 关于它的元问题 - (来自@ImmortalBlue的详细信息)
- 一个茶壶 - joereddington.com/projects/418 .. - ( @MegaTom的详细信息)
- Snarked - www.snarked.org/coffee - (来自@ MR.X的详细信息)
- 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)
Websites that have implemented it
这篇关于是否有语言/软件实现http状态代码418?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!