【问题标题】:Difficulty implementing the teapot protocol茶壶协议难以实现
【发布时间】:2016-01-19 02:20:58
【问题描述】:

我正在尝试在我的网站上实现 HTTP 客户端错误 418,但遇到了困难。我在 PHP 中尝试了一个实现:

http_response_code(418);

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

提前感谢您的帮助!

【问题讨论】:

    标签: php apache google-app-engine http


    【解决方案1】:

    所以,http_response_code 函数显然是 isn't written 来处理 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。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多