git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitweb: in-page errors don't work with mod_perl
@ 2011-11-27  4:05 Jürgen Kreileder
  2011-11-27 22:43 ` Jakub Narebski
       [not found] ` <201111280138.02511.jnareb@gmail.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Jürgen Kreileder @ 2011-11-27  4:05 UTC (permalink / raw)
  To: git

Hi

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.


Jürgen

-- 
http://blog.blackdown.de/
http://www.flickr.com/photos/jkreileder/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
  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
  2011-11-28  0:20   ` Jürgen Kreileder
       [not found] ` <201111280138.02511.jnareb@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2011-11-27 22:43 UTC (permalink / raw)
  To: Jürgen Kreileder; +Cc: git

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
  2011-11-27 22:43 ` Jakub Narebski
@ 2011-11-28  0:20   ` Jürgen Kreileder
  0 siblings, 0 replies; 8+ messages in thread
From: Jürgen Kreileder @ 2011-11-28  0:20 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

2011/11/27 Jakub Narebski <jnareb@gmail.com>:
> 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?

Not really.  It does make the errors appear inline on the standard gitweb pages.
But the HTTP status code is broken now: It's always 200 OK.


> 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
>
>

Jürgen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
       [not found]     ` <201111281754.59205.jnareb@gmail.com>
@ 2011-11-28 20:13       ` Jürgen Kreileder
  2011-11-28 21:42         ` Jürgen Kreileder
  0 siblings, 1 reply; 8+ messages in thread
From: Jürgen Kreileder @ 2011-11-28 20:13 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:
 [...]
>
> The configuration is very similar.  Perhaps that is the difference between
> Apache 2.0.x (mine) and Apache 2.2.x (yours).
>
> Does adding `$r->err_headers_out();` before `$r->status(200);` helps?
> I'm grasping at straws here.  mod_perl documentation is not very helpful.

Doesn't help unfortunately.  It's hard to find any information about
this on the net (except for your comment on stackoverflow :).

The only way to get mod_perl to return a custom error message with
correct status code I've found so far is $r->custom_response($status,
$msg).  Unfortunately mod_perl then ignores header I set, e.g.
content-type.


Juergen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
  2011-11-28 20:13       ` Jürgen Kreileder
@ 2011-11-28 21:42         ` Jürgen Kreileder
  2011-11-28 22:32           ` Jakub Narebski
  0 siblings, 1 reply; 8+ messages in thread
From: Jürgen Kreileder @ 2011-11-28 21:42 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:
> On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:
>  [...]
>>
>> The configuration is very similar.  Perhaps that is the difference between
>> Apache 2.0.x (mine) and Apache 2.2.x (yours).
>>
>> Does adding `$r->err_headers_out();` before `$r->status(200);` helps?
>> I'm grasping at straws here.  mod_perl documentation is not very helpful.
>
> Doesn't help unfortunately.  It's hard to find any information about
> this on the net (except for your comment on stackoverflow :).
>
> The only way to get mod_perl to return a custom error message with
> correct status code I've found so far is $r->custom_response($status,
> $msg).  Unfortunately mod_perl then ignores headers I set, e.g.
> content-type.

I guess this explains it:
http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml
Requires quite some restructuring to gitweb.perl.


Juergen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
  2011-11-28 21:42         ` Jürgen Kreileder
@ 2011-11-28 22:32           ` Jakub Narebski
  2011-11-28 23:40             ` Jürgen Kreileder
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2011-11-28 22:32 UTC (permalink / raw)
  To: Jürgen Kreileder; +Cc: git

Jürgen Kreileder wrote:
> On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:
> > On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:
> >  [...]
> > >
> > > The configuration is very similar.  Perhaps that is the difference between
> > > Apache 2.0.x (mine) and Apache 2.2.x (yours).
> > >
> > > Does adding `$r->err_headers_out();` before `$r->status(200);` helps?
> > > I'm grasping at straws here.  mod_perl documentation is not very helpful.
> >
> > Doesn't help unfortunately.  It's hard to find any information about
> > this on the net (except for your comment on stackoverflow :).
> >
> > The only way to get mod_perl to return a custom error message with
> > correct status code I've found so far is $r->custom_response($status,
> > $msg).  Unfortunately mod_perl then ignores headers I set, e.g.
> > content-type.
> 
> I guess this explains it:
> http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml
> Requires quite some restructuring to gitweb.perl.

I'm coming close to declaring that ModPerl::Registry is horribly broken
with respect to error pages created by CGI, and say that we don't support
it, removing mod_perl configuration examples from gitweb documentation.

WTF 'return Apache2::Const::DONE;' doesn't work with ModPerl::Registry?
It is supposed to work with native mod_perl scripts...

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
  2011-11-28 22:32           ` Jakub Narebski
@ 2011-11-28 23:40             ` Jürgen Kreileder
  2011-11-29  0:49               ` Jakub Narebski
  0 siblings, 1 reply; 8+ messages in thread
From: Jürgen Kreileder @ 2011-11-28 23:40 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On Mon, Nov 28, 2011 at 23:32, Jakub Narebski <jnareb@gmail.com> wrote:
> Jürgen Kreileder wrote:
>> On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:
>> > On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:
>> >  [...]
>> > >
>> > > The configuration is very similar.  Perhaps that is the difference between
>> > > Apache 2.0.x (mine) and Apache 2.2.x (yours).
>> > >
>> > > Does adding `$r->err_headers_out();` before `$r->status(200);` helps?
>> > > I'm grasping at straws here.  mod_perl documentation is not very helpful.
>> >
>> > Doesn't help unfortunately.  It's hard to find any information about
>> > this on the net (except for your comment on stackoverflow :).
>> >
>> > The only way to get mod_perl to return a custom error message with
>> > correct status code I've found so far is $r->custom_response($status,
>> > $msg).  Unfortunately mod_perl then ignores headers I set, e.g.
>> > content-type.
>>
>> I guess this explains it:
>> http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml
>> Requires quite some restructuring to gitweb.perl.
>
> I'm coming close to declaring that ModPerl::Registry is horribly broken
> with respect to error pages created by CGI, and say that we don't support
> it, removing mod_perl configuration examples from gitweb documentation.

Makes sense.  The benefits of mod_perl are properly small for gitweb anyway.


Juergen

-- 
http://blog.blackdown.de/
http://www.flickr.com/photos/jkreileder/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gitweb: in-page errors don't work with mod_perl
  2011-11-28 23:40             ` Jürgen Kreileder
@ 2011-11-29  0:49               ` Jakub Narebski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2011-11-29  0:49 UTC (permalink / raw)
  To: Jürgen Kreileder; +Cc: git

Jürgen Kreileder wrote:
> On Mon, Nov 28, 2011 at 23:32, Jakub Narebski <jnareb@gmail.com> wrote:
>> Jürgen Kreileder wrote:
>>> On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:
>>>> On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:
>>>>  [...]
>>>>>
>>>>> The configuration is very similar.  Perhaps that is the difference between
>>>>> Apache 2.0.x (mine) and Apache 2.2.x (yours).
>>>>>
>>>>> Does adding `$r->err_headers_out();` before `$r->status(200);` helps?
>>>>> I'm grasping at straws here.  mod_perl documentation is not very helpful.
>>>>
>>>> Doesn't help unfortunately.  It's hard to find any information about
>>>> this on the net (except for your comment on stackoverflow :).
>>>>
>>>> The only way to get mod_perl to return a custom error message with
>>>> correct status code I've found so far is $r->custom_response($status,
>>>> $msg).  Unfortunately mod_perl then ignores headers I set, e.g.
>>>> content-type.
>>>
>>> I guess this explains it:
>>> http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml
>>> Requires quite some restructuring to gitweb.perl.
>>
>> I'm coming close to declaring that ModPerl::Registry is horribly broken
>> with respect to error pages created by CGI, and say that we don't support
>> it, removing mod_perl configuration examples from gitweb documentation.
> 
> Makes sense.  The benefits of mod_perl are properly small for gitweb anyway.

Anyway you can run gitweb with FastCGI (supposedly - I don't know if it
was tested), which provides the same (or most of the) advantages that
mod_perl gives, without the troubles.  Just rename gitweb.cgi to
gitweb.fcgi and configure web server appropriately (and have FCGI Perl
module installed).

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-11-29  0:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).