Re: gitweb: in-page errors don't work with mod_perl
Hello!
Jürgen Kreileder <jk@blackdown.de> 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.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
...
</html><!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 ... was not found on this server.</p>
<hr>
<address>Apache/2.0.54 (Fedora) Server at localhost Port 80</address>
</body></html>
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 <jk@blackdown.de>
Signed-off-by: Jakub Narębski <jnareb@gmail.com>
---
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