Subject: | [PATCH] The value of $engine->return persists across requests |
Discovered a really weird problem when working on a migration from mod_perl.
Occasionally, a page request would have two responses. That is, I'd get
a 404 not found page AND the catalyst response page at the same time.
Eventually, I tracked it down to the fact that $engine->return is not
cleared on each new request. If a previous request declined to handle a
uri ($engine->return(-1)), then C::E::Apache will return -1 for the
current request and all future requests, regardless if Catalyst can
handle the request or not. This would result in both Apache and Catalyst
trying to handle the request, hence two responses.
After talking with Andy Grudman, the solution is to clear out return in
prepare_request.
I've attached a patch for this fix.
Subject: | clear_return_on_every_request.patch |
Index: lib/Catalyst/Engine/Apache.pm
===================================================================
--- lib/Catalyst/Engine/Apache.pm (revision 7443)
+++ lib/Catalyst/Engine/Apache.pm (working copy)
@@ -21,6 +21,9 @@
sub prepare_request {
my ( $self, $c, $r ) = @_;
$self->apache( $r );
+ # Clear out the return from a previous request, if any
+ # Need to do this because $engine will persist across requests
+ $self->return(undef);
}
sub prepare_connection {