httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <>
Subject Re: How to control block size of input_filter data
Date Tue, 12 Mar 2013 09:36:22 GMT
On 2013-03-12 10:16, Hoang-Vu Dang wrote:
> Hi all,
> When I write an input_filter, I notice that the data sent from client is
> not always available in one chunk if it's large.
> In other words, The input_filter() function will be called multiple
> times per request. My question is how to have a control on this (for
> example the size of the chunk until it breaks in to two) ? what should
> we look into in order to check if the two filters are called from the
> same request.

You can keep the state from one filter invokation to the other in 
f->ctx, the filter's context.

There are many ways to do this.

One way I've seen is to check if f->ctx is NULL (if it was NULL then it 
would mean that it is the first invokation of the filter). If it's NULL, 
we build the context. Subsequent invokations have the context != NULL. 
You'll have to destroy the context at the end of the request. I 
typically destroy it by placing a callback in the cleanup hook of the 

Another way to destroy it, but in my opinion a wrong way, is to destroy 
it when you encounter EOS in the data processed by the filter. I'd say 
it's wrong because a wrongly written filter could send data _after_ an 
EOS bucket and then you could not distinguish between a new request and 
a request sending data after EOS.

Another way to initialize the context is by placing a filter init 
function when you declare the filter and to initialize the context in 
this function. This is more elegant in my opinion, because the context 
is already initialized when the filter is called the first time.

The filter context could be any structure, so you can track the filter 
processing state in it.


View raw message