You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "John D.Lima" <li...@5cats.org> on 2004/02/19 20:08:02 UTC
[mp2] arg for Apache::RequestRec::proxyreq()
Hi,
[Apache 2.0.48/mod_perl 1.99_12, linux (debian) 2.4.x]
Anyone using the $val arg for Apache::RequestRec::proxyreq(), per
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_proxyreq_ ?
synopsis:
$ret = $r->proxyreq($val);
* arg1: $r (Apache::RequestRec)
* arg2: $val (integer)
* ret: $ret (integer)
Looking at the source it appears that you can pass zero, perhaps to
prevent proxying of the current request? That's what I'd like to do:
I have a PerlPostReadRequestHandler running on a proxy server (using
mod_proxy)
that wants to intercept/handle various requests directly while proxying
others
normally. To achieve this I currently match against the
'$r->unparsed_uri()' and
actually clear PerlTransHandler ('$r->set_handlers(PerlTransHandler =>
undef);')
and set my response handler according to my match mapping.
I'd like to just call '$r->proxyreq(0)' to disable mod_proxy for this
one request
and let my response handler do the right thing later on, but it seems
to have no
effect. Any plans for this, or am I barking up the wrong tree here?
Cheers,
--jd.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] arg for Apache::RequestRec::proxyreq()
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I
> played with setting my dispatch handler as a PerlTransHandler, but
> mod_proxy seems
> to get in there first no matter how I setup the config file, so I got it
> in at the
> PerlPostReadRequestHandler. But for what it's worth, examining proxyreq
> value in
> later phases (access, response) it still reports =1, whether I
> '$r->proxyreq(0)' or
> not. I'll respond more directly to Geoff's note if I have anything
> useful to report.
if you have the tuits, try changing modperl_hooks.c from this
ap_hook_trans(modperl_trans_handler, NULL, NULL, APR_HOOK_FIRST);
to this
ap_hook_trans(modperl_trans_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
don't rerun 'perl Makefile.PL...' - just make && sudo make install and see
if setting proxyreq(0) in a PerlTransHandler then holds. if it does, then
it's a symptom of a larger issue I've been meaning to tackle.
> Thanks for the pointer to modperlcookbook (have it, use it, love it :)
:)
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] arg for Apache::RequestRec::proxyreq()
Posted by "John D.Lima" <li...@5cats.org>.
On Feb 19, 2004, at 12:35 PM, Stas Bekman wrote:
*snip*
>> I have a PerlPostReadRequestHandler running on a proxy server (using
>> mod_proxy)
>> that wants to intercept/handle various requests directly while
>> proxying others
>> normally.
>> [...]
>> I'd like to just call '$r->proxyreq(0)' to disable mod_proxy for this
>> one request
>> and let my response handler do the right thing later on, but it seems
>> to have no
>> effect. Any plans for this, or am I barking up the wrong tree here?
>
> I think what you need is to fixup the $->filename and $r->uri as well.
> Let me write some tests and see whether this works.
Thanks for the tip -- I set both $r->filename and $r->uri to match a
<Location..>
section and got the results I wanted. As usual, you rock, Stas!
I also found that $r->proxyreq(0) now makes no difference to the
browser as far
as I can tell from simple testing, though my access handler and
response callback
-- set from the PerlPostReadRequestHandler mapping -- do see some
differences in
$r as they run: absolute vs. relative filename & uri...
I need to look into Geoff's reply and see if I can make further
improvements. I
played with setting my dispatch handler as a PerlTransHandler, but
mod_proxy seems
to get in there first no matter how I setup the config file, so I got
it in at the
PerlPostReadRequestHandler. But for what it's worth, examining
proxyreq value in
later phases (access, response) it still reports =1, whether I
'$r->proxyreq(0)' or
not. I'll respond more directly to Geoff's note if I have anything
useful to report.
Thanks for the pointer to modperlcookbook (have it, use it, love it :)
Cheers,
-jd.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] arg for Apache::RequestRec::proxyreq()
Posted by Stas Bekman <st...@stason.org>.
John D.Lima wrote:
> Hi,
>
> [Apache 2.0.48/mod_perl 1.99_12, linux (debian) 2.4.x]
>
> Anyone using the $val arg for Apache::RequestRec::proxyreq(), per
> http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_proxyreq_ ?
>
> synopsis:
> $ret = $r->proxyreq($val);
>
> * arg1: $r (Apache::RequestRec)
> * arg2: $val (integer)
> * ret: $ret (integer)
> Looking at the source it appears that you can pass zero, perhaps to
> prevent proxying of the current request? That's what I'd like to do:
>
> I have a PerlPostReadRequestHandler running on a proxy server (using
> mod_proxy)
> that wants to intercept/handle various requests directly while proxying
> others
> normally. To achieve this I currently match against the
> '$r->unparsed_uri()' and
> actually clear PerlTransHandler ('$r->set_handlers(PerlTransHandler =>
> undef);')
> and set my response handler according to my match mapping.
>
> I'd like to just call '$r->proxyreq(0)' to disable mod_proxy for this
> one request
> and let my response handler do the right thing later on, but it seems to
> have no
> effect. Any plans for this, or am I barking up the wrong tree here?
I think what you need is to fixup the $->filename and $r->uri as well. Let me
write some tests and see whether this works.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] arg for Apache::RequestRec::proxyreq()
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I have a PerlPostReadRequestHandler running on a proxy server (using
> mod_proxy)
> that wants to intercept/handle various requests directly while proxying
> others
> normally. To achieve this I currently match against the
> '$r->unparsed_uri()' and
> actually clear PerlTransHandler ('$r->set_handlers(PerlTransHandler =>
> undef);')
that will only clear mod_perl translation handlers - mod_proxy's translation
handler will still run. if you want to totally subvert the translation
phase you need to set a handler that simply returns Apache::OK.
> and set my response handler according to my match mapping.
>
> I'd like to just call '$r->proxyreq(0)' to disable mod_proxy for this
> one request
if you set that from a PerlPostReadRequestHandler it may be having no effect
because both mod_perl and mod_proxy call use APR_HOOK_FIRST, so there is no
guarantee that what you unset won't be reset by mod_proxy. it would be
interesting to see the value for $r->proxyreq in a PerlTransHandler after
you try to unset it. just a guess, though.
nevertheless, you probably need to do your $r->proxyreq(0) logic in a
PerlTransHandler. see, for example
http://www.modperlcookbook.org/code/ch12/Cookbook/MirrorApache.pm
which is recipe 12.5 in the book. while it's talking about Apache 1.3, you
ought to be able to control 2.0 in pretty much the same way (the new
map-to-storage logic might make things a bit different, but I don't think so).
unfortunately, we don't have that chapter online - there are some
explanations in there that might help clear things up a bit.
HTH
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html