I wanted to do something similar, but the Apache 2 APIs require a
request_rec* in the lookup_uri method.  Tracing the code in request.c, it
uses the passed in request_rec* in make_sub_request.

The example Joe provided won't compile, and the request_rec can't be NULL
otherwise the code will segfault.  Any other ways to do this?

On Tue, Apr 20, 2010 at 4:35 PM, Joe Lewis <j...@joe-lewis.com> wrote:

> ((template_context *)f->ctx)->include_r =
> ap_sub_req_lookup_uri(uri,f->r,((template_context
> *)f->ctx)->include_filter);
>  apr_table_setn(((template_context
> *)f->ctx)->include_r->notes,TEMPLATE_OVERRIDE_PARSER,"-");
>  if ((((template_context *)f->ctx)->include_r != NULL) &&
> (((template_context *)f->ctx)->include_r->status == HTTP_OK)) {
> #ifdef DEBUG
> ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "mod_template:
> mod_template_include() - calling ap_run_sub_req()");
>
> On Apr 20, 2010, at 2:20 PM, <markus.l...@dlr.de> <markus.l...@dlr.de>
> wrote:
>
> >
> > Hi. Can I build a request completely free and send it with
> > ap_run_sub_req? I could not find any good documentation or examples.
> >
> > Thanks
> > Markus
>
> I learn by reading a lot of examples.  So, a very simple example :
>
>
> request_rec                   *req;
> int        retval;
> ap_filter_t     *filters;
>
> filters = NULL;
> req = ap_sub_req_lookup_uri("/robots.txt",filters);
> retval = ap_run_sub_req(req);
>
>
> Note that it sends the data back to the client, so if you are trying to
> capture the output of the sub request, you will have to create a filter that
> doesn't pass, but simply gathers the info.
>
> Joe

Reply via email to