perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander V. Lukyanov" <>
Subject a bug with redirect in mod_perl-2.0.3 and CGI-3.25
Date Thu, 15 Feb 2007 15:01:33 GMT

I have a perl script which uses CGI package and does redirect(). It is run
under mod_perl. For some reason I get HTTP status "200 OK", but the header
"Location:" is set and the response body says the document has moved.

I have debugged it somewhat, found that send_cgi_header is correctly called
by CGI's redirect, the function send_cgi_header sets r->status to 302 and
r->status_line to "302 Moved" correctly. But then the status is reset to
200 in RegistryCooker::default_handler. Then Apache's validate_status_line
function finds mismatch between status and status_line and resets the
status_line to "200 OK" too.

I beleave there is a bug somewhere which prevents redirecting from CGI when
using mod_perl. I fixed it by this patch, but I'm not sure it is "the right
way" (TM):

---	Thu Feb 15 17:57:00 2007
+++	Thu Feb 15 17:40:59 2007
@@ -168,7 +168,7 @@
     # status after running it
     my $old_status = $self->{REQ}->status;
     my $rc = $self->run;
-    my $new_status = $self->{REQ}->status($old_status);
+    my $new_status = $self->{REQ}->status; #($old_status);
     return ($rc == Apache2::Const::OK && $old_status != $new_status)
         ? $new_status
         : $rc;


View raw message