You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Pawel Niewiadomski <ne...@foo-baz.com> on 2005/01/12 14:10:36 UTC

[apache-2.1.3] buffering content in input filter

hello,
I'm writing an input filter that needs to operate on a full content
of incoming request. But it should not pass incoming data to other
input filters - it gathers full body of request, changes it and then
passes it further.

I have one problem - if I empty a brigade that is passed to the input filter
it is not called again.
I read that free brigades mean that input is ended. If I leave a byte in the
brigade everything works ok - input filter is called until
EOS and I can dump previously gathered content. But I don't want to
add these bytes. 

Does anyone know how can I solve this problem?

-- 
**Paweł Niewiadomski**, new()foo-baz.com, http://new.foo-baz.com/
Virtual Qmail (http://v-q.foo-baz.com), qmail-patches (http://q-p.foo-baz.com)


Re: [apache-2.1.3] buffering content in input filter

Posted by Stas Bekman <st...@stason.org>.
Pawel Niewiadomski wrote:
> hello,
> I'm writing an input filter that needs to operate on a full content
> of incoming request. But it should not pass incoming data to other
> input filters - it gathers full body of request, changes it and then
> passes it further.
> 
> I have one problem - if I empty a brigade that is passed to the input filter
> it is not called again.
> I read that free brigades mean that input is ended. If I leave a byte in the
> brigade everything works ok - input filter is called until
> EOS and I can dump previously gathered content. But I don't want to
> add these bytes. 
> 
> Does anyone know how can I solve this problem?
> 

Instead of returning empty brigades up the stream, you can gobble up all 
incoming data by issuing your own ap_get_brigade calls. I don't have 
example in C, but you can see how it's done in perl:
t/filter/TestFilter/in_bbs_consume.pm
http://svn.apache.org/viewcvs.cgi/perl/modperl/trunk/t/filter/TestFilter/in_bbs_consume.pm?rev=106958&view=markup

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

Re: [apache-2.1.3] buffering content in input filter

Posted by Nick Kew <ni...@webthing.com>.
On Wed, 12 Jan 2005, Nick Kew wrote:

> [a fairly useless message]

I meant to add: there are C code examples in my stuff at
apache.webthing.com.  Can't recollect OTTOMH what's published, but
mod_upload is definitely opensource and its tmpfile_filter does
what you're asking (though it's not an ideal example).

-- 
Nick Kew

Re: [apache-2.1.3] buffering content in input filter

Posted by Nick Kew <ni...@webthing.com>.
On Wed, 12 Jan 2005, Pawel Niewiadomski wrote:

> Does anyone know how can I solve this problem?

As Stas says, simply don't return to the caller until you've got EOS.

You lose the efficiency of pipelining, and beware of how big a request
you accept and buffer!



-- 
Nick Kew