On Tue, 18 Aug 2009 13:56:51 +0200, Sorin Manolache <sor...@gmail.com> wrote: > On Tue, Aug 18, 2009 at 08:38, Michael Spiegle<m...@nauticaltech.com> > wrote: >> Nick Kew wrote: >>> >>> Michael Spiegle wrote: >>>> >>>> Hello, >>>> I have a module I am writing which implements a content-generator and >>>> a filter. If I make a sub-request from within my content-generator, >>>> the filter's (request_rec*)f->r only points to the original request. >>>> How do I access the current sub-request from within my filter? >>> >>> How do you know the subrequest exists at the point where you access >>> it from the filter? >>> >>> Put whatever you need on your module's filter's context. >>> >> >> >> I was hoping that when my filter starts receiving data for a subrequest, >> the >> request_rec* attached to the filter would indicate that it was a >> subrequest >> via f->r->main not being NULL. It seems like you can use that logic >> everywhere else, so why not in the filter context? >> > > I use the following code: > > request_rec *newreq = ap_sub_req_lookup_uri(url, req, NULL); > ap_filter_t *flt = ap_add_output_filter(FILTER_NAME, NULL, newreq, > newreq->connection); > // flt->ctx = &flt_ctx; > int ret_code = ap_run_sub_req(newreq); > ap_destroy_sub_req(newreq); > > The filter is > > apr_status_t output_filter(ap_filter_t *f, apr_bucket_brigade *bb) { > // f->r->main is not NULL ! > } > > This code works for me. > > I hope this helps. > > S
Wow, I feel like an idiot. I had the same thing you just posted except my ap_add_ouput_filter() function used the old request instead of 'newreq'. This fix seems to have solved my issue. Thank you very much! -- Michael Spiegle