Re: mp2] [mod_proxy] [filter] mod_proxy is not playing with my request filter.

André Warnier <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
James Lee wrote:
> Hi mod_perl community, this is my first post so be gentle with me.
> 
> I'm trying to create something which translates a GET request into a POST
> (creating the body dynamically) and then hand off the POST to another
> server.
> 
> I have created a mod_perl connection filter to change the GET to a POST in
> the request line. It also adds Content-Length and Content-Type headers and
> this works fine.
> 
> I then have a request filter which creates the POST body. This works when
> the request is handled by a PerlResponseHandler but I'm trying to offload
> the request to mod_proxy as the responses can be quite large but I just
> can't get it to play ball. I see the request filter being called but the
> POST body never arrives at the target server. I suspect this is a timing
> issue, ie: mod_proxy kicking in before my request filter but I'm not
> certain.

Exactly. By the time your response handler is invoked, the time for mod_proxy is long past.

One approach would be : have your PerlResponseHandler send the request directly to the 
back-end server, using LWP, read the response, and return this response as the response 
for your response handler.  In other words, do yourself what mod_proxy would do.

> 
> Can anybody shed some light on this or correct my approach. I was going to
> add the POST body in the connection filter but it seemed cleaner/easier to
> do it in a request filter.

In the mod_perl documentation, there is somewhere a schema of the different Apache phases, 
and when the different handlers get invoked.  I beliebe mod_proxygets invoked somewhere 
around the Fixup phase, so if you want to beat it, you have to be earlier than that.

> 
> I've looked on the mailing list and found a few things that touch on this (
> http://tech.groups.yahoo.com/group/modperl/message/54541) but nothing that's
> close enough to help.
> 
> Config below ... I've not included perl code as this message is quite long
> anyway. Please let me know if it would be helpful.
> Thanks in advance, James.
> 
> 
> ***
> httpd.conf extract:
> 
> 
> PerlInputFilterHandler Sample::RequestTweaker::change_get_to_post
> 
> <Location /reports>
>    PerlInputFilterHandler Sample::RequestTweaker::inject_post_data
>    ProxyPass http://appserver/reports-engine
> </Location>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.