是否有语言/软件实现http状态代码418? [英] Are there languages/software that implements http status code 418?

查看:265
本文介绍了是否有语言/软件实现http状态代码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)



网站实施了它



查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆