git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: gitweb: in-page errors don't work with mod_perl

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 27, 2011, 22:43 UTC
Message-ID
<m339d9mbiu.fsf@localhost.localdomain>
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
Previous: Jürgen KreilederNext: Jürgen Kreileder
Message 2 of 8 in “gitweb: in-page errors don't work with mod_perl”
  1. Jürgen KreilederNov 27, 2011
  2. Jakub NarebskiNov 27, 2011
  3. Jürgen KreilederNov 28, 2011
  4. Jürgen KreilederNov 28, 2011
  5. Jürgen KreilederNov 28, 2011
  6. Jakub NarebskiNov 28, 2011
  7. Jürgen KreilederNov 28, 2011
  8. Jakub NarebskiNov 29, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.