John D.Lima wrote:

On Mar 12, 2004, at 5:12 PM, Stas Bekman wrote:


John D.Lima wrote:

*snip*


For clarity (?): my PerlPreConnectionHandler works great on browser requests
coming into the proxy, but it runs again when the server response to the proxied
request returns _to the proxy_. In this server response case I want to do
something slightly different based on the _server's_ IP. But I don't know how to
easily determine if this (server response) connection is actually due to the
proxy's own subrequest, and not another client browser connecting.


I don't think that qualifies as an Apache sub-request. Are you talking about "sub-request" to a remote server? If it's a local subrequest, it won't use a new connection, and therefore won't invoke PerlPreConnectionHandler.


yep, my mistake for calling it a subrequest...

If that's a remote request (like LWP'ing), why do you say that the response from the remote server creates a new connection?


Yes, this is (mostly) the case. The remote server response to the proxy is apparently
due to mod_proxy's action just after the fixup phase of the original request into the
proxy. I'm saying the remote server response appears to make another connection to the
proxy because the same PerlPreConnectionHandler runs a second time.

Yup, I've skimmed through the mod_proxy source and that's exactly what it does.


It would seem the PerlPreConnectionHandler catches both. BUT how would I distinguish
between the two, aside from IP?

It seems that it'll use the same connection pool, server and id when it proxies an HTTP request. from proxy_http.c:


        /* the socket is now open, create a new backend server connection */
        *origin = ap_run_create_connection(c->pool, r->server, p_conn->sock,
                                           r->connection->id,
                                           r->connection->sbh,
                                           c->bucket_alloc);

So you could probably try one of the following:

* set a note in $c->base_server and then read it in the second connection
* track $c->id (should be the same id in both)
* set user data in the $c->pool and read it in the second connection

I haven't tested any of these, just thinking that this might be right from looking at proxy_http.c and other source files under httpd-2.0/modules/proxy/

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] 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



Reply via email to