我,其实是个Teapot……并不是Apache httpd
418变成500。
前几天我在使用 Apache httpd 的时候,试图显示”418 I’m A Teapot”,但却收到了500 Internal Server Error的错误提示。
Redirect 418 /
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
403状态码是可以正常工作的。
在进行调查后,我发现在手册中有写明。
状态必须是有效的HTTP状态码,已知于Apache HTTP服务器(请参考http_protocol.c中的send_error_response函数)。
确实,它设为了 NULL 呢。
https://github.com/apache/httpd/blob/2.4.x/modules/http/http_protocol.c#L135
"415 Unsupported Media Type",
"416 Requested Range Not Satisfiable",
"417 Expectation Failed",
NULL, /* 418 */
NULL, /* 419 */
NULL, /* 420 */
"421 Misdirected Request",
"422 Unprocessable Entity",
"423 Locked",
噢,是你的时间到了吗?
在这种情况下,作为专门实施无用物品的专家,难道不正是我的时候吗?
我以为不是,在这个Github链接的Apache httpd trunk的模块的http_protocol.c文件的第135行的代码中已经有了!
"415 Unsupported Media Type",
"416 Requested Range Not Satisfiable",
"417 Expectation Failed",
"418 I'm A Teapot",
NULL, /* 419 */
NULL, /* 420 */
"421 Misdirected Request",
"422 Unprocessable Entity",
"423 Locked",
听说在httpd 2.6 (或者3.0) 可以使用呢。
有点遗憾。
截至2020年7月,甚至连Alpha版都还没有发布。