Hi,

I am currently migrating an apache module to the 2.0 API. I have some 
problems with the sub requests and I couldn't find documentation about it.

When browsing to a http server where the module with the below source is 
activated, I want to get the answer ABC, but I only get B (or when 
adding some ap_rflush() calls, I get AB). What do I need to change here ?

Joerg


#include "httpd.h"
#include "http_config.h"
#include "http_main.h"
#include "http_protocol.h"

static int foo(request_rec *r)
{
     if( 'b' != r->uri[strlen(r->uri)-1] )
     {
         ap_rwrite( "A", 1 , r );
         {
             /* now call the else branch , include 'B' */
             request_rec *rn = ap_sub_req_lookup_uri( "b", r,0 );
             ap_run_sub_req(rn);
             ap_destroy_sub_req(rn);
         }
         ap_rwrite( "C", 1 , r );
     }
     else
     {
         ap_rwrite( "B" , 1 , r );
     }

     /* This should give ABC, but I get B */
     return OK;
}

static void register_hooks(apr_pool_t *p)
{
     ap_hook_handler(foo, NULL, NULL, APR_HOOK_REALLY_FIRST);
}

module AP_MODULE_DECLARE_DATA foo_module =
{
     STANDARD20_MODULE_STUFF,
     0,  /* create per-directory config structures */
     0,  /* merge per-directory config structures  */
     0,  /* create per-server config structures    */
     0,  /* merge per-server config structures     */
     0, /* command handlers */
     register_hooks /* register hooks */
};

Reply via email to