perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: Apache2 filters questions
Date Wed, 03 Aug 2005 18:59:08 GMT
Javier Alonso Sánchez wrote:
> Hi all.
> 
> I'm fighting hard with Apache2 filters  + mod_perl, and I have some
> doubts to ask you:
> 
> I want to analyze a POST request to my Apache2 server, analyze it, and
> change the headers to redirect the POST to another uri, depending on
> the content (body of the POST).
> 
> As I need body+headers, I'm using a Input Connection Filter.
> 
> The main problem is how to stop the buckets brigades. It's easy to
> analyze the body, but when I process it, the brigades with headers
> have just passed to the next filter (or the core).
> 
> In order to "stop" the previous brigades, I read all the brigades
> using a loop which knows when the body finishes, reading
> Content-Length header. As I use Connection Filter, and there isn't
> EOS, it is the unique way to know WHEN the filter must stop getting
> brigades .... Are there any way else to know it ??

It's very tricky, as Apache doesn't give you any indication of that event. 
I've solved this in a hacky way. which is explained here:
http://perl.apache.org/docs/2.0/user/handlers/filters.html#Connection_Filters_over_KeepAlive_Connections
and is used in http://search.cpan.org/dist/Apache-Filter-HTTPHeadersFixup/

> Is there another way to modify the header of a request once processed
> the body content?

I think you are much better off not to use a filter here. Use 
Apache::Request which can give the same POST body more than once. So I'd 
write a trans hander, which grabs the body, rewrites the headers based on 
the body and the content handler can still get the body (this is only 
available in libapreq2)


-- 
__________________________________________________________________
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

Mime
View raw message