From: Jakub Narebski Date: Sun, 27 Nov 2011 22:43:20 GMT Subject: Re: gitweb: in-page errors don't work with mod_perl Message-ID: In-Reply-To: Hello! Jürgen Kreileder writes: > when gitweb.perl (208a1cc3d3) is run with mod_perl2 (2.0.5-2ubuntu1 on > Ubuntu 11.10) custom error pages don't work: Any page with status != > 200 shows the plain Apache error document instead of a gitweb's error > page. Thanks for reporting it. I wonder if it worked at all anytime... Anyway, does the following patch fixes this issue for you? -- >8 -- Subject: [PATCH] gitweb: Fix error handling for mod_perl When gitweb was run with mod_perl2 (using ModPerl::Registry), the custom error pages don't work: Any page with status != 200 had the plain Apache error document appended to a gitweb's error page, e.g. 404 Not Found

Not Found

The requested URL ... was not found on this server.


Apache/2.0.54 (Fedora) Server at localhost Port 80
When serving gitweb with application/xhtml+xml mimetype this results in malformed XML and some browsers do not showing output at all. The solution used by this commit is to tell mod_perl that it is O.K., and we handled all errors by ourselves. This make us not depend in whether there is or not PerlOptions +ParseHeaders in Apache configuration section for mod_perl. Reported-by: Jürgen Kreileder Signed-off-by: Jakub Narębski --- gitweb/gitweb.perl | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 4f0c3bd..f51cce1 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1239,6 +1239,11 @@ sub run { run(); +if ($ENV{'MOD_PERL'}) { + # mod_perl needs to be told that error page was already created + my $r = $cgi->r; + $r->status(200); +} if (defined caller) { # wrapped in a subroutine processing requests, # e.g. mod_perl with ModPerl::Registry, or PSGI with Plack::App::WrapCGI -- 1.7.6