Apache/2.2.9,mod_perl/2.0.4:status_line donds';好像不行
答复是这样准备的:Apache/2.2.9,mod_perl/2.0.4:status_line donds';好像不行,apache,mod-perl,Apache,Mod Perl,答复是这样准备的: my $r = Apache2::RequestUtil->request; $r->status_line('500 Internal Server Error'); $r->send_cgi_header("Content-Type: text/html; charset=UTF-8\n\n"); print 'Custom error message'; 请求: GET /test_page HTTP/1.1 Host: www.xxx.xxx 答
my $r = Apache2::RequestUtil->request;
$r->status_line('500 Internal Server Error');
$r->send_cgi_header("Content-Type: text/html; charset=UTF-8\n\n");
print 'Custom error message';
请求:
GET /test_page HTTP/1.1
Host: www.xxx.xxx
答复:
HTTP/1.1 200 OK
Date: XXXXXXXXXX
Server: Apache/xxxxxxxx
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
44
Custom error message
0
为什么响应状态是200而不是500?这是注册表脚本还是处理程序 在响应处理程序中,如果要设置4xx或5xx状态,则需要返回
Apache2::status::DONE
,而不是Apache2::status::OK
发件人:
HTTP处理程序也可能返回
Apache2::Const::DONE告诉
Apache停止正常的HTTP请求
循环并快进到
PerlLogHandler,然后是
PerlCleanupHandler。HTTP处理程序可能会
返回任何HTTP状态,该状态
与Apache2::Const::DONE类似
导致请求周期中止,
由也将被解释为
错误。所以你不想
从返回Apache2::Const::HTTP\u确定
您的HTTP响应处理程序,但是
Apache2::Const::OK,Apache将
自行发送200 OK状态
希望这能有所帮助-我记得我花了相当长的时间在文档中寻找这个,我想其他地方都没有提到过 $r->custom\u响应(500,$custom\u错误消息)必须用于此目的