git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: "Jürgen Kreileder" <jk@blackdown.de>
Cc: git@vger.kernel.org
Subject: Re: gitweb: in-page errors don't work with mod_perl
Date: Sun, 27 Nov 2011 14:43:20 -0800 (PST)	[thread overview]
Message-ID: <m339d9mbiu.fsf@localhost.localdomain> (raw)
In-Reply-To: <CAKD0UuweWoY5ObXgyN9vrOXWrKdNYWuG7CGB0V7HvcuiwRJD+A@mail.gmail.com>

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

  reply	other threads:[~2011-11-27 22:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-27  4:05 gitweb: in-page errors don't work with mod_perl Jürgen Kreileder
2011-11-27 22:43 ` Jakub Narebski [this message]
2011-11-28  0:20   ` Jürgen Kreileder
     [not found] ` <201111280138.02511.jnareb@gmail.com>
     [not found]   ` <CAKD0UuyDUPJFkpWbj2qFYsnii+6WoABnokhhhx4PysPW0FX2sA@mail.gmail.com>
     [not found]     ` <201111281754.59205.jnareb@gmail.com>
2011-11-28 20:13       ` Jürgen Kreileder
2011-11-28 21:42         ` Jürgen Kreileder
2011-11-28 22:32           ` Jakub Narebski
2011-11-28 23:40             ` Jürgen Kreileder
2011-11-29  0:49               ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m339d9mbiu.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jk@blackdown.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).