perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <ge...@modperlcookbook.org>
Subject Apache::RegistryNG fix
Date Wed, 30 Jan 2002 14:34:21 GMT
hi guys...

sorry for keeping down the 1.3 path - I'll get with the program
eventually...

I was playing around with Apache::RegistryNG and found what seems to
be a bug.

Apache::Registry and Apache::RegistryNG do not behave the same wrt
redirects.

with Apache::RegistryNG, the simple redirect script:

print "Location: http://www.foo.com";

returns

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Moved</TITLE>
</HEAD><BODY>
<H1>Moved</H1>
The document has moved <A
HREF="http://mainsheet.laserlink.net/">here</A>.<P>
<P>Additionally, a 302 Found
error was encountered while trying to use an ErrorDocument to handle
the request.
<HR>
<ADDRESS>Apache/1.3.24-dev Server at mainsheet.laserlink.com Port
80</ADDRESS>
</BODY></HTML>

basically, it looks like Apache is entering into its recursive
ErrorDocument cycle.

after a bit of research, I came up with the below patch.  it basically
mimics what Apache::Registry does wrt $r->status: true handlers aren't
supposed to set $r->status themselves, but instead return the proper
HTTP code to indicate what they want to do.  what was happening was
that $r->status was being set to 302 in PerlRun and handler() was
returning 302 as well, so Apache thinks the error is recursive.  at
least that's my theory.

so, with this patch, Apache::RegistryNG traps the old status code and
restores it after the handler is run, which is the same thing that
Apache::Registry does.

--Geoff

Index: lib/Apache/RegistryNG.pm
===================================================================
RCS file: /home/cvspublic/modperl/lib/Apache/RegistryNG.pm,v
retrieving revision 1.7
diff -u -r1.7 RegistryNG.pm
--- lib/Apache/RegistryNG.pm    28 Sep 2000 19:59:39 -0000      1.7
+++ lib/Apache/RegistryNG.pm    30 Jan 2002 14:26:46 -0000
@@ -48,9 +48,15 @@
        $pr->set_mtime;
     }
 
+    my $old_status = $r->status;
+
     $rc = $pr->run(@_);
     $pr->chdir_file("$Apache::Server::CWD/");
-    return ($rc != OK) ? $rc : $pr->status;
+
+    my $pr_status = $pr->status;
+    $r->status($old_status);
+
+    return ($rc != OK) ? $rc : $pr_status;
 }
 
 1;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message