我试图在我的网站上实现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.
更多推荐
发布评论