You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Issac Goldstand <ma...@beamartyr.net> on 2006/09/11 15:29:38 UTC

[users@httpd] Forcing an input filter to process the request data

Hi all,

I'm trying to write an extension to mod_cache that will allow methods
other than GET to be cached.  As such, I wrote my own key generation
routine which inserts an input filter in the request chain, slurps in
all of the request data, and calculates an MD5 digest, which it then
Base64 encodes and sets as the key for the cached content (instead of
the traditional full URI).  My problem is that the generate key function
can't wait until the response handler runs (at least, not in the
traditional mod_cache layout, as I understand it), so I need to try to
force the request to be read, or at least get it through my filter,
earlier, and I'm not quite sure how to go about doing that.

Originally, I tried to base my logic on mod_apreq2's
apreq_filter_prefetch routine, but I ended up with an endless loop when
calling ap_get_brigade on f->next until it returned !APR_SUCCESS or
until the key was ready (stored in ctx->key)

Then, I realized that f->next would be pulling the data only up until
the next upstream filter (which works fine for apreq, since it just
passes the brigades it gets to the parser without the filter actually
needing to do anything), and so I tried switching the call to
ap_get_brigade to use f, instead of f->next.  That solved the evil
endless memory-gobbling loop, but now I seem to be getting a single EOS
bucket and that's it (my filter is set to finalize the md5 and remove
itself from the chain after getting an EOS bucket).  I thought that
maybe the problem was that I'm using the quick-handler, and the input
stream might not be available yet, but other handlers (tried
header_parser, post_request_read and fixups) seemed to give me the same
problem.

Can anyone more knowledgeable point me in the right direction (including
something to read on the subject of input filters or a better forum for
this question)?

Thanks,
  Issac

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org