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 Tue, 11 May 2010 19:49:02 GMT
This would have been in the parent process in the monitor hook or used in
the child init hook.  The ability to use it in either would be good.  I
think the easiest approach for me would be to use libCurl or an equivalent
simple client side lib.  I'm not sure how to properly populate a
request_rec* so I don't want to touch it, unless there are APIs that can
build one for me easily without relying on an existing request_rec* to begin
with.

Thanks for your help,

SB

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

> On May 6, 2010, at 4:22 PM, Some Guy wrote:
>
> > 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.
>
> Question:  when is the code being called?  On an incoming request?  Or is
> this something you are trying to do with a pool clean up?  Or init?  Since
> this is an apache module, it will have some sort of a hook, most can work
> (e.g. filters will still have a request).
>
> So, if you don't have a request_rec structure anywhere because you are
> using the sub_request to log something to log something on a hook that has
> nothing to do with an incoming connection, it comes down to you building and
> populating the request_rec from scratch or using libcurl.  It really depends
> on your ultimate objective here.
>
> Joe
>
>
>
>
> >
> > 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