You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Querna <ch...@force-elite.com> on 2004/10/09 02:59:54 UTC

Capturing a Subrequest

I am trying to capture the content of a sub request that I create in my 
module (mod_transform) to a bucket brigade. I want to do this so libxml2 
can use it as an input buffer.  As an example, this would allow 
mod_transform to XInclude content from another Handler (PHP, mod_perl, 
or my own module...).

I looked through the mail archives & google, and couldn't find anyone 
else that has done this.

Some people tried doing it with mod_perl more than a year ago, but ended 
  up fetching it over HTTP via LWP, not capturing the output of a sub 
request.

I cannot seem to get my output filter ran by Apache.  I tried tracing 
through it with GDB, but it is being quite stubborn on my sparc tonight.

My output filter looks like:

static apr_status_t
apachefs_filter(ap_filter_t * f, apr_bucket_brigade * bb)
{
     apr_status_t rv;
     apr_bucket_brigade *data = f->ctx;
     rv = ap_save_brigade(f, &data, &bb, f->r->pool);
     f->ctx = data;
     return rv;
}

However, my capturing output filter doesn't seem to ever be called.

So, I think something about my manually adding my output filter
to the subrequest is wrong:

ap_filter_t cf;
....
cf.frec = ap_get_output_filter_handle(APACHEFS_FILTER_NAME);
cf.next = NULL;
cf.ctx = input_ctx->bb;
cf.r = f->r;
cf.c = f->c;
....
rr = ap_sub_req_lookup_uri(URI, f->r, &cf);
....
rr_status = ap_run_sub_req(rr);

If I pass NULL as the 3rd arg to ap_sub_req_lookup_uri(...) it will use 
my current request's filters.  I don't want the content sent to the 
client, I just want it buffered to a bucket brigade.

Is there a better way to do this?

-Paul Querna

Re: Capturing a Subrequest

Posted by Paul Querna <ch...@force-elite.com>.
Cliff Woolley wrote:
> On Fri, 8 Oct 2004, Paul Querna wrote:
> 
> 
>>So, I think something about my manually adding my output filter
>>to the subrequest is wrong:
> 
> 
> Ya, that doesn't look right.  There a function that's called (or at least
> used to be called ;) "ap_add_output_filter()".  That's probably what you
> want.

Thanks for the reality check. It works now. :)

-Paul

Re: Capturing a Subrequest

Posted by Cliff Woolley <jw...@virginia.edu>.
On Fri, 8 Oct 2004, Paul Querna wrote:

> So, I think something about my manually adding my output filter
> to the subrequest is wrong:

Ya, that doesn't look right.  There a function that's called (or at least
used to be called ;) "ap_add_output_filter()".  That's probably what you
want.

--Cliff