我正在开发一个RESTful API,并且我写了一个mod_perl2处理程序来处理请求。通过设置$r->status($http_code)
和return $http_code;
如何禁止mod_perl中的默认apache错误文档?
一切都与错误代码
我处理的交易是很好,除了一个小问题:当我的HTTP_CODE是不同于200(例如404),阿帕奇追加一个默认的HTML错误文件到我的自己产生的回应。
例如:
GET /foo
给出:
$VAR1 = bless({
'status' => 404,
'data' => {},
'message' => 'Resource not found for foo'
}, 'My::Response');
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /foo was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache/2.0.54 (Fedora) Server at localhost Port 80</address>
</body></html>
如何摆脱这个阿帕奇生成的HTML?
更新:我的错。我的mod_perl2处理程序正在返回一个HTTP_ *代码,而不是Apache2 :: Const :: OK。
当阿帕奇::常量不支持像201 HTTP状态代码,你会如何解决这个问题,在Apache 1.3而mod_perl 1.XX? – 2011-06-01 03:51:12