RESTful API를 개발 중이며 요청을 처리하는 mod_perl2 핸들러를 작성했습니다. $r->status($http_code)
및 return $http_code;
mod_perl에서 기본 아파치 오류 문서를 어떻게 억제합니까?
모두를 설정하여 오류 코드와
내 핸들러 거래는 약간의 문제를 제외하고 괜찮 : 내 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 처리기가 Apache2 :: Const :: OK 대신 HTTP_ * 코드를 반환했습니다.
Apache :: Constants가 201과 같은 HTTP 상태 코드를 지원하지 않으면 어떻게 아파치 1.3 및 mod_perl 1.xx에서이 문제를 해결할 수 있습니까? –