本文介绍了我如何燮preSS在mod_perl的默认的Apache的错误文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个RESTful API和我写了一个mod_perl2处理程序,接受请求的照顾。

I'm developing a RESTful API and I wrote a mod_perl2 handler that takes care of the request.

我处理的交易通过设置 $ R 34 GT;状态($ HTTP code)收益$ HTTP_ code;

My handler deals with error codes by setting $r->status($http_code) and return $http_code;

一切都很好,除了一个小问题:当我HTTP_ code是不同的超过200(例如404),阿帕奇追加一个默认的HTML错误文档我自己生成的响应

Everything is fine, except a little problem: when my http_code is different than 200 (for instance 404), apache appends a default HTML error document to my own generated response.

例如:

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?

How do I get rid of this apache generated HTML?

更新:我的错。我mod_perl2处理程序返回一个HTTP_ * code代替的Apache2 ::常量::确定。

推荐答案

请参阅的。我没有时间,现在做实验,但应该工作。

See Apache2::Response. I do not have time to experiment right now, but that should work.

这篇关于我如何燮preSS在mod_perl的默认的Apache的错误文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 12:16