httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dennis J." <>
Subject Re: Trouble with filter-module, function called multiple times
Date Sun, 05 Apr 2009 15:25:58 GMT
On 04/05/2009 11:18 AM, Alexander Hjalmarsson wrote:
> The problem with this seems to be that this function is for some pages
> called three of four times and it looks like it is "forked" or something and
> splits up the content and separates them and goes through the function three
> or four times and because of this, the code can appear more times on one
> page since in the first piece of the page it will find the body and insert
> after that, but in the other pieces it will just try to insert on the "top"
> of that piece since the body tag is not found, which results in broken pages
> etc because it can appear anywhere.

You filter will be called for each "chunk" of data apache delivers to the 
client. That has two consequences for you:

1. You cannot maintain state in local variables in the function. Check out 
your mod_txt example and notice how the variable f->ctxt->state is used for 
this purpose.

2. Since in your particular case you can only make the decision whether to 
insert the header at the top of the file or not after you scanned the whole 
file you'll have to buffer the data until you receive an EOS bucket and 
then flush out the accumulated content.


View raw message