perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>
Subject Re: mod_perl - Intercepting an external Redirect
Date Wed, 19 Sep 2007 16:16:48 GMT
Am Mittwoch, 19. September 2007 schrieb Perrin Harkins:
> On 9/19/07, Torsten Krah <tkrah@fachschaft.imn.htwk-leipzig.de> wrote:
> > So in short, i need to analyze the response of mod_proxy and if it
> > matches some criteria, i want to do a internal redirect and serve some
> > content under the requested url.
> > The client should not see the "external redirect" the servlet triggers.
> >
> > I hope i can do this with a ResponseHandler, but as i am new to this
> > stuff, i don't know if this is the "right" way.
>
> I think a filter is what you want.  It sounds like mod_proxy is your
> response handler already.  A filter can step in afterward and change
> the response.
>
> - Perrin

Thx for this hint.
Reading the filters.pod and looking at the examples i'll still got a problem.

I've configured mod_proxy to deliver content from server otherhost (simulates 
the tomcat) and otherhost2 (which should deliver the content in special cases 
but be hidden from the user).

RewriteEngine on
RewriteRule ^/time/(.*)$ http://otherhost.local/$1 [P,L]
RewriteRule ^/extern/(.*)$  http://otherhost2.local/$1     [P,L]

PerlModule MyApache2::FilterRequestFoo
<Location /time>
     SetHandler modperl
     PerlOutputFilterHandler MyApache2::FilterRequestFoo::Filter
</Location>

The module does nothing special yet, as i want to see if it gets called on 
redirects (if this is done i can do the logic stuff when to deliver original 
content or when to do a internal_redirect to deliver content from otherhost2.

sub Filter {
     my ($f, $bb) = @_;
     my $r=$f->r; 
     warn "Called Filter";
     $r->internal_redirect("/extern/hidden_document");
     return Apache2::Const::OK;
}

If i request /time/XYZ the filter get called and the internal_redirect is 
done, i get the content of "otherhost2" under the original request put 
on "otherhost".

Now i configured the "otherhost" to do a permanent redirect when /time/blog is 
requested.
If i request this uri, the redirect is done like configured there - my filter 
does not get called.

Did i miss something? 

Torsten

Mime
View raw message