Jonathan Vanasco <[EMAIL PROTECTED]> [08-12-2006 21:50]:
> On Dec 7, 2006, at 3:37 PM, Sumit Shah wrote:
>> I want the request to come to My::RequestHandler FIRST and then go  
>> to the ProxyPass Directive. It does not do this. It BYPASSES my  

I've been working on something like this recently...

[...]
> So you've got the chance to call a mp hook on  
> PerlPostReadRequestHandler or PerlTransHandler

IIRC (can't check at the moment of writing this) I got it working with
PerlPostReadRequestHandler.

> Unfortunately, for that to happen under the current design of Apache/ 
> ModPerl/and ModProxy, you probably won't have the data you want  
> available ( i believe you only have access to the URI at that phase )

IIRC URI and headers; I haven't tested if POST data is available.

> In order to get what you want done, you'll have to handle the Proxy  
> internally -- ie, write a perl handler that will fetch the page using  
> LWP or something, and then pass that content on.

This would be slow and is not necessary; just implement the ProxyPass
logic in mod_perl and set:

  $r->proxyreq(Apache2::Const::PROXYREQ_REVERSE);

(Note: this constant has value of 2 and isn't mentioned in proxyreq()'s
documentation.  Patch attached.  There might also be something not quite
right with the $r->unparsed_uri description.)

-- 
Radosław Zieliński <[EMAIL PROTECTED]>
--- mod_perl-2.0.3-rc3/docs/api/Apache2/RequestRec.pod~ 2006-11-19 
02:31:48.000000000 +0100
+++ mod_perl-2.0.3-rc3/docs/api/Apache2/RequestRec.pod  2006-12-12 
18:48:54.622291000 +0100
@@ -1479,12 +1479,13 @@
 
 =item opt arg1: C<$val> ( integer )
 
-0, 1 or none.
+C<Apache2::Const::PROXYREQ_NONE>, C<Apache2::Const::PROXYREQ_PROXY>,
+C<Apache2::Const::PROXYREQ_REVERSE> or none.
 
 =item ret: C<$status> ( integer )
 
-If C<$val> is 0 or 1, the I<proxyrec> member will be set to that value
-and previous value will be returned.
+If C<$val> is 0, 1 or 2, the I<proxyrec> member will be set to that
+value and previous value will be returned.
 
 If C<$val> is not passed, and C<$r-E<gt>proxyreq> is not true, and the
 proxy request is matching the current vhost (scheme, hostname and
@@ -1500,8 +1501,9 @@
 For example to turn a normal request into a proxy request to be
 handled on the same server in the C<PerlTransHandler> phase run:
 
+  use Apache2::Const -compile => qw(:proxy);
   my $real_url = $r->unparsed_uri;
-  $r->proxyreq(1);
+  $r->proxyreq(Apache2::Const::PROXYREQ_PROXY);
   $r->uri($real_url);
   $r->filename("proxy:$real_url");
   $r->handler('proxy-server');
@@ -1509,7 +1511,7 @@
 Also remember that if you want to turn a proxy request into a
 non-proxy request, it's not enough to call:
 
-  $r->proxyreq(0);
+  $r->proxyreq(Apache2::Const::PROXYREQ_NONE);
 
 You need to adjust C<$r-E<gt>uri> and C<$r-E<gt>filename> as well if
 you run that code in C<PerlPostReadRequestHandler> phase, since if you

Attachment: pgpgtq04v5dvd.pgp
Description: PGP signature

Reply via email to