httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Some Guy <teknos...@gmail.com>
Subject Re: Doing a subrequest with ap_run_sub_req
Date Thu, 06 May 2010 22:22:10 GMT
What we want to do is create the subrequest (or maybe just a request)
without any previous request_rec* object.  At least that is what I figured
markus meant when he said "build a request completely free".  From the APIs,
this does not seem possible, and using libCurl may be the better solution.

On Thu, May 6, 2010 at 12:40 PM, Joe Lewis <joe@joe-lewis.com> wrote:

> On May 6, 2010, at 8:40 AM, Some Guy wrote:
>
> > 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?
>
> There are many ways - you can use libCURL to make the request, or you can
> revisit the two code examples I gave you.  One was from my memory, then
> realizing I had forgotten a lot of it, I scraped some code from a functional
> module.  Did you notice both examples?  The bottom one was just to point you
> in the right direction.  I have simplified the other one that I had scraped
> from a functional module, and stuffed it into a fresh module generated by
> "apxs -g -n subrequest", and it compiled quite nicely.  The diff :
>
> 47a48,55
> >     request_rec       *subr;
> >     int return_code;
> >     subr = ap_sub_req_lookup_uri("/index.html",r,NULL);
> >     if ((subr != NULL) && (subr->status == HTTP_OK)) {
> >         return_code = ap_run_sub_req(subr);
> >         ap_destroy_sub_req(subr);
> >     }
> >
>
>
> I am presuming you copied and pasted my over simplified example at the
> bottom of my response rather than using the top code section.
>
>
>
>
> >
> > On Tue, Apr 20, 2010 at 4:35 PM, Joe Lewis <joe@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.litz@dlr.de> <markus.litz@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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message