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

烈酒焚心 提交于 2019-12-03 04:21:19

Google does it.

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

www.google.com/teapot

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)

Yes, it is implemented (by a teapot).

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

Immortal Blue

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.

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!