You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Marc Lambrichs <ml...@melange-it.nl> on 2005/08/08 22:53:06 UTC
redirect doesn't work in eval
When a request is sent to the webserver, it handles some stuff and then
- sometimes - a redirect must take place. Now the weird part:
when i use
$r->headers_out->set( Location => 'http://www.mysite.com/' );
return Apache2::Const::REDIRECT
inside an eval{} construction it doesn't work. Is there any logic to this?
Marc
Re: redirect doesn't work in eval
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Marc Lambrichs wrote:
> When a request is sent to the webserver, it handles some stuff and then
> - sometimes - a redirect must take place. Now the weird part:
>
> when i use
> $r->headers_out->set( Location => 'http://www.mysite.com/' );
> return Apache2::Const::REDIRECT
> inside an eval{} construction it doesn't work. Is there any logic to this?
Works for me: (Did I misunderstand?)
You can see this in action at
http://p6m7g8.net/redirect
and
http://p6m7g8.net/redirect_with_eval
<Location /redirect>
SetHandler modperl
PerlResponseHandler TEST::Redirect
</Location>
<Location /redirect_with_eval>
SetHandler modperl
PerlResponseHandler TEST::RedirectE
</Location>
package TEST::Redirect;
use strict;
use warnings FATAL => 'all';
use Carp;
use Apache2::Request ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(REDIRECT);
sub handler {
my $r = shift;
$r->headers_out->set(Location => 'http://google.com');
return Apache2::Const::REDIRECT;
}
1;
package TEST::RedirectE;
use strict;
use warnings FATAL => 'all';
use Carp;
use Apache2::Request ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(REDIRECT);
sub handler {
my $r = shift;
eval {
$r->headers_out->set(Location => 'http://yahoo.com');
return Apache2::Const::REDIRECT;
}
}
--
END
------------------------------------------------------------
What doesn't kill us can only make us stronger.
Nothing is impossible.
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
http://www.liquidityservicesinc.com
http://www.liquidation.com
http://www.uksurplus.com
http://www.govliquidation.com
http://www.gowholesale.com