难以实施茶壶协议(Difficulty implementing the teapot protocol)

编程入门 行业动态 更新时间:2024-10-24 16:29:30
难以实施茶壶协议(Difficulty implementing the teapot protocol)

我试图在我的网站上实现HTTP客户端错误418并遇到困难。 我在PHP中尝试过一个实现:

http_response_code(418);

这让我在我的Mac本地APACHE和我的网站部署的Google App Engine上都出现了500错误。 因为谷歌已经实施了这个协议,我认为这在他们的一个系统中会相对简单,但是我被卡住了。 我的网站不是IETF RFC 2324中定义的咖啡壶,所以我不确定如何继续。

在此先感谢您的帮助!

I am attempting to implement HTTP Client Error 418 on my website and running into difficulty. I have tried an implementation in PHP:

http_response_code(418);

which gives me a 500 error both in APACHE locally on my Mac and on Google App Engine where my website is deployed. Because Google has implemented this protocol I assumed that this would be relatively simple in one of their systems, but I am stuck. My site is not a coffee pot as defined in IETF RFC 2324 so I am unsure how to proceed.

Thanks in advance for your help!

最满意答案

因此, http_response_code函数显然不是为了处理418而写的,这意味着你必须自己编写它:

$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'); header($protocol . " 418 I'm a teapot"); $GLOBALS['http_response_code'] = 418;

我已通过APACHE和Google App Engine在本地进行了验证。

So, the http_response_code function apparently isn't written to handle a 418 meaning you have to write it yourself:

$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'); header($protocol . " 418 I'm a teapot"); $GLOBALS['http_response_code'] = 418;

Which I have verified works both locally with APACHE and on Google App Engine.

更多推荐

本文发布于:2023-08-05 19:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1438358.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:茶壶   协议   Difficulty   protocol   teapot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!