{"thread":{"id":"29025","subject":"gitweb: in-page errors don't work with mod_perl","startedAt":"2011-11-27T04:05:55Z","lastAt":"2011-11-29T00:49:36Z","messageCount":8,"participants":["Jürgen Kreileder","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"179999","messageId":"CAKD0UuweWoY5ObXgyN9vrOXWrKdNYWuG7CGB0V7HvcuiwRJD+A@mail.gmail.com","threadId":"29025","inReplyTo":null,"subject":"gitweb: in-page errors don't work with mod_perl","fromName":"Jürgen Kreileder","fromEmail":"jk@blackdown.de","sentAt":"2011-11-27T04:05:55Z","receivedAt":"2011-11-27T04:05:55Z","isPatch":false,"sender":{"key":"jk@blackdown.de","avatar":"https://avatars.githubusercontent.com/u/4390544?v=4"},"body":"Hi\n\nwhen gitweb.perl (208a1cc3d3) is run with mod_perl2 (2.0.5-2ubuntu1 on\nUbuntu 11.10) custom error pages don't work: Any page with status !=\n200 shows the plain Apache error document instead of a gitweb's error\npage.\n\n\nJürgen\n\n-- \nhttp://blog.blackdown.de/\nhttp://www.flickr.com/photos/jkreileder/\n"},{"id":"180025","messageId":"m339d9mbiu.fsf@localhost.localdomain","threadId":"29025","inReplyTo":"CAKD0UuweWoY5ObXgyN9vrOXWrKdNYWuG7CGB0V7HvcuiwRJD+A@mail.gmail.com","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-11-27T22:43:20Z","receivedAt":"2011-11-27T22:43:20Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Hello!\n\nJürgen Kreileder <jk@blackdown.de> writes:\n\n> when gitweb.perl (208a1cc3d3) is run with mod_perl2 (2.0.5-2ubuntu1 on\n> Ubuntu 11.10) custom error pages don't work: Any page with status !=\n> 200 shows the plain Apache error document instead of a gitweb's error\n> page.\n\nThanks for reporting it.  I wonder if it worked at all anytime...\n\nAnyway, does the following patch fixes this issue for you?\n\n-- >8 --\nSubject: [PATCH] gitweb: Fix error handling for mod_perl\n\nWhen gitweb was run with mod_perl2 (using ModPerl::Registry), the\ncustom error pages don't work: Any page with status != 200 had the\nplain Apache error document appended to a gitweb's error page, e.g.\n\n  <?xml version=\"1.0\" encoding=\"utf-8\"?>\n  <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n  ...\n  </html><!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n  <html><head>\n  <title>404 Not Found</title>\n  </head><body>\n  <h1>Not Found</h1>\n  <p>The requested URL ... was not found on this server.</p>\n  <hr>\n  <address>Apache/2.0.54 (Fedora) Server at localhost Port 80</address>\n  </body></html>\n\nWhen serving gitweb with application/xhtml+xml mimetype this results\nin malformed XML and some browsers do not showing output at all.\n\n\nThe solution used by this commit is to tell mod_perl that it is O.K.,\nand we handled all errors by ourselves.\n\nThis make us not depend in whether there is or not\n\n  PerlOptions +ParseHeaders\n\nin Apache configuration section for mod_perl.\n\nReported-by: Jürgen Kreileder <jk@blackdown.de>\nSigned-off-by: Jakub Narębski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 4f0c3bd..f51cce1 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1239,6 +1239,11 @@ sub run {\n \n run();\n \n+if ($ENV{'MOD_PERL'}) {\n+\t# mod_perl needs to be told that error page was already created\n+\tmy $r = $cgi->r;\n+\t$r->status(200);\n+}\n if (defined caller) {\n \t# wrapped in a subroutine processing requests,\n \t# e.g. mod_perl with ModPerl::Registry, or PSGI with Plack::App::WrapCGI\n-- \n1.7.6\n"},{"id":"180028","messageId":"CAKD0UuwJoRkd7J06d2mFgyN0tO8p8ETPrwW5DqX12m+c_tQz4A@mail.gmail.com","threadId":"29025","inReplyTo":"m339d9mbiu.fsf@localhost.localdomain","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jürgen Kreileder","fromEmail":"jk@blackdown.de","sentAt":"2011-11-28T00:20:41Z","receivedAt":"2011-11-28T00:20:41Z","isPatch":false,"sender":{"key":"jk@blackdown.de","avatar":"https://avatars.githubusercontent.com/u/4390544?v=4"},"body":"2011/11/27 Jakub Narebski <jnareb@gmail.com>:\n> Jürgen Kreileder <jk@blackdown.de> writes:\n>\n>> when gitweb.perl (208a1cc3d3) is run with mod_perl2 (2.0.5-2ubuntu1 on\n>> Ubuntu 11.10) custom error pages don't work: Any page with status !=\n>> 200 shows the plain Apache error document instead of a gitweb's error\n>> page.\n>\n> Thanks for reporting it.  I wonder if it worked at all anytime...\n>\n> Anyway, does the following patch fixes this issue for you?\n\nNot really.  It does make the errors appear inline on the standard gitweb pages.\nBut the HTTP status code is broken now: It's always 200 OK.\n\n\n> Reported-by: Jürgen Kreileder <jk@blackdown.de>\n> Signed-off-by: Jakub Narębski <jnareb@gmail.com>\n> ---\n>  gitweb/gitweb.perl |    5 +++++\n>  1 files changed, 5 insertions(+), 0 deletions(-)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 4f0c3bd..f51cce1 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -1239,6 +1239,11 @@ sub run {\n>\n>  run();\n>\n> +if ($ENV{'MOD_PERL'}) {\n> +       # mod_perl needs to be told that error page was already created\n> +       my $r = $cgi->r;\n> +       $r->status(200);\n> +}\n>  if (defined caller) {\n>        # wrapped in a subroutine processing requests,\n>        # e.g. mod_perl with ModPerl::Registry, or PSGI with Plack::App::WrapCGI\n> --\n> 1.7.6\n>\n>\n\nJürgen\n"},{"id":"180064","messageId":"CAKD0Uuws=zU+Pg8afn91mm0t4Rp_GNF++dTYnjA9okndyR=cXQ@mail.gmail.com","threadId":"29025","inReplyTo":"201111281754.59205.jnareb@gmail.com","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jürgen Kreileder","fromEmail":"jk@blackdown.de","sentAt":"2011-11-28T20:13:28Z","receivedAt":"2011-11-28T20:13:28Z","isPatch":false,"sender":{"key":"jk@blackdown.de","avatar":"https://avatars.githubusercontent.com/u/4390544?v=4"},"body":"On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:\n [...]\n>\n> The configuration is very similar.  Perhaps that is the difference between\n> Apache 2.0.x (mine) and Apache 2.2.x (yours).\n>\n> Does adding `$r->err_headers_out();` before `$r->status(200);` helps?\n> I'm grasping at straws here.  mod_perl documentation is not very helpful.\n\nDoesn't help unfortunately.  It's hard to find any information about\nthis on the net (except for your comment on stackoverflow :).\n\nThe only way to get mod_perl to return a custom error message with\ncorrect status code I've found so far is $r->custom_response($status,\n$msg).  Unfortunately mod_perl then ignores header I set, e.g.\ncontent-type.\n\n\nJuergen\n"},{"id":"180065","messageId":"CAKD0UuzsV7A_j8YD4b0Lb95L2NcRcSu5PH8C9aZQmEx3tOuQjQ@mail.gmail.com","threadId":"29025","inReplyTo":"CAKD0Uuws=zU+Pg8afn91mm0t4Rp_GNF++dTYnjA9okndyR=cXQ@mail.gmail.com","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jürgen Kreileder","fromEmail":"jk@blackdown.de","sentAt":"2011-11-28T21:42:16Z","receivedAt":"2011-11-28T21:42:16Z","isPatch":false,"sender":{"key":"jk@blackdown.de","avatar":"https://avatars.githubusercontent.com/u/4390544?v=4"},"body":"On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:\n> On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:\n>  [...]\n>>\n>> The configuration is very similar.  Perhaps that is the difference between\n>> Apache 2.0.x (mine) and Apache 2.2.x (yours).\n>>\n>> Does adding `$r->err_headers_out();` before `$r->status(200);` helps?\n>> I'm grasping at straws here.  mod_perl documentation is not very helpful.\n>\n> Doesn't help unfortunately.  It's hard to find any information about\n> this on the net (except for your comment on stackoverflow :).\n>\n> The only way to get mod_perl to return a custom error message with\n> correct status code I've found so far is $r->custom_response($status,\n> $msg).  Unfortunately mod_perl then ignores headers I set, e.g.\n> content-type.\n\nI guess this explains it:\nhttp://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml\nRequires quite some restructuring to gitweb.perl.\n\n\nJuergen\n"},{"id":"180067","messageId":"201111282332.07276.jnareb@gmail.com","threadId":"29025","inReplyTo":"CAKD0UuzsV7A_j8YD4b0Lb95L2NcRcSu5PH8C9aZQmEx3tOuQjQ@mail.gmail.com","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-11-28T22:32:06Z","receivedAt":"2011-11-28T22:32:06Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jürgen Kreileder wrote:\n> On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:\n> > On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:\n> >  [...]\n> > >\n> > > The configuration is very similar.  Perhaps that is the difference between\n> > > Apache 2.0.x (mine) and Apache 2.2.x (yours).\n> > >\n> > > Does adding `$r->err_headers_out();` before `$r->status(200);` helps?\n> > > I'm grasping at straws here.  mod_perl documentation is not very helpful.\n> >\n> > Doesn't help unfortunately.  It's hard to find any information about\n> > this on the net (except for your comment on stackoverflow :).\n> >\n> > The only way to get mod_perl to return a custom error message with\n> > correct status code I've found so far is $r->custom_response($status,\n> > $msg).  Unfortunately mod_perl then ignores headers I set, e.g.\n> > content-type.\n> \n> I guess this explains it:\n> http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml\n> Requires quite some restructuring to gitweb.perl.\n\nI'm coming close to declaring that ModPerl::Registry is horribly broken\nwith respect to error pages created by CGI, and say that we don't support\nit, removing mod_perl configuration examples from gitweb documentation.\n\nWTF 'return Apache2::Const::DONE;' doesn't work with ModPerl::Registry?\nIt is supposed to work with native mod_perl scripts...\n\n-- \nJakub Narebski\nPoland\n"},{"id":"180070","messageId":"CAKD0Uuw35Kdno=OxqP5SYtaVjqUFZCLL9fSSscN7sq=KmycyxA@mail.gmail.com","threadId":"29025","inReplyTo":"201111282332.07276.jnareb@gmail.com","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jürgen Kreileder","fromEmail":"jk@blackdown.de","sentAt":"2011-11-28T23:40:27Z","receivedAt":"2011-11-28T23:40:27Z","isPatch":false,"sender":{"key":"jk@blackdown.de","avatar":"https://avatars.githubusercontent.com/u/4390544?v=4"},"body":"On Mon, Nov 28, 2011 at 23:32, Jakub Narebski <jnareb@gmail.com> wrote:\n> Jürgen Kreileder wrote:\n>> On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:\n>> > On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:\n>> >  [...]\n>> > >\n>> > > The configuration is very similar.  Perhaps that is the difference between\n>> > > Apache 2.0.x (mine) and Apache 2.2.x (yours).\n>> > >\n>> > > Does adding `$r->err_headers_out();` before `$r->status(200);` helps?\n>> > > I'm grasping at straws here.  mod_perl documentation is not very helpful.\n>> >\n>> > Doesn't help unfortunately.  It's hard to find any information about\n>> > this on the net (except for your comment on stackoverflow :).\n>> >\n>> > The only way to get mod_perl to return a custom error message with\n>> > correct status code I've found so far is $r->custom_response($status,\n>> > $msg).  Unfortunately mod_perl then ignores headers I set, e.g.\n>> > content-type.\n>>\n>> I guess this explains it:\n>> http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml\n>> Requires quite some restructuring to gitweb.perl.\n>\n> I'm coming close to declaring that ModPerl::Registry is horribly broken\n> with respect to error pages created by CGI, and say that we don't support\n> it, removing mod_perl configuration examples from gitweb documentation.\n\nMakes sense.  The benefits of mod_perl are properly small for gitweb anyway.\n\n\nJuergen\n\n-- \nhttp://blog.blackdown.de/\nhttp://www.flickr.com/photos/jkreileder/\n"},{"id":"180072","messageId":"201111290149.36931.jnareb@gmail.com","threadId":"29025","inReplyTo":"CAKD0Uuw35Kdno=OxqP5SYtaVjqUFZCLL9fSSscN7sq=KmycyxA@mail.gmail.com","subject":"Re: gitweb: in-page errors don't work with mod_perl","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-11-29T00:49:36Z","receivedAt":"2011-11-29T00:49:36Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jürgen Kreileder wrote:\n> On Mon, Nov 28, 2011 at 23:32, Jakub Narebski <jnareb@gmail.com> wrote:\n>> Jürgen Kreileder wrote:\n>>> On Mon, Nov 28, 2011 at 21:13, Jürgen Kreileder <jk@blackdown.de> wrote:\n>>>> On Mon, Nov 28, 2011 at 17:54, Jakub Narebski <jnareb@gmail.com> wrote:\n>>>>  [...]\n>>>>>\n>>>>> The configuration is very similar.  Perhaps that is the difference between\n>>>>> Apache 2.0.x (mine) and Apache 2.2.x (yours).\n>>>>>\n>>>>> Does adding `$r->err_headers_out();` before `$r->status(200);` helps?\n>>>>> I'm grasping at straws here.  mod_perl documentation is not very helpful.\n>>>>\n>>>> Doesn't help unfortunately.  It's hard to find any information about\n>>>> this on the net (except for your comment on stackoverflow :).\n>>>>\n>>>> The only way to get mod_perl to return a custom error message with\n>>>> correct status code I've found so far is $r->custom_response($status,\n>>>> $msg).  Unfortunately mod_perl then ignores headers I set, e.g.\n>>>> content-type.\n>>>\n>>> I guess this explains it:\n>>> http://foertsch.name/ModPerl-Tricks/custom-content_type-with-custom_response.shtml\n>>> Requires quite some restructuring to gitweb.perl.\n>>\n>> I'm coming close to declaring that ModPerl::Registry is horribly broken\n>> with respect to error pages created by CGI, and say that we don't support\n>> it, removing mod_perl configuration examples from gitweb documentation.\n> \n> Makes sense.  The benefits of mod_perl are properly small for gitweb anyway.\n\nAnyway you can run gitweb with FastCGI (supposedly - I don't know if it\nwas tested), which provides the same (or most of the) advantages that\nmod_perl gives, without the troubles.  Just rename gitweb.cgi to\ngitweb.fcgi and configure web server appropriately (and have FCGI Perl\nmodule installed).\n\n-- \nJakub Narebski\nPoland\n"}]}