Commit 39175ff5 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Add a hook, create_request. This hook allows modules to modify

a request while it is being created.  This hook is called for all
request_rec's, main request, sub request, and internal redirect.
When this hook is called, the the r->main, r->prev, r->next
pointers have been set, so modules can determine what kind of
request this is.

Currently, this is only used by the core module, but protocol modules
are going to need to have the ability to affect the request while it is
being read.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88532 13f79535-47bb-0310-9956-ffa450edef68
parent 99992592
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.15-dev

  *) Add a hook, create_request.  This hook allows modules to modify
     a request while it is being created.  This hook is called for all
     request_rec's, main request, sub request, and internal redirect.
     When this hook is called, the the r->main, r->prev, r->next
     pointers have been set, so modules can determine what kind of
     request this is.  [Ryan Bloom]

  *) Cleanup the build process a bit more.  The Apache configure
     script no longer creates its own helper scripts, it just
     uses APR's.  
+8 −0
Original line number Diff line number Diff line
@@ -247,6 +247,14 @@ AP_DECLARE(void) ap_die(int type, request_rec *r);
 * doxygen (Ben).
 */

/**
 * Gives modules a chance to create their request_config entry when the
 * request is created.
 * @param r The current request
 * @ingroup hooks
 */
AP_DECLARE_HOOK(void,create_request,(request_rec *r))

/**
 * This hook allow modules an opportunity to translate the URI into an
 * actual filename.  If no modules do anything special, the server's default
+5 −4
Original line number Diff line number Diff line
@@ -424,7 +424,6 @@ static apr_table_t *rename_original_env(apr_pool_t *p, apr_table_t *t)
static request_rec *internal_internal_redirect(const char *new_uri,
					       request_rec *r) {
    int access_status;
    core_request_config *req_cfg;
    request_rec *new = (request_rec *) apr_pcalloc(r->pool,
						   sizeof(request_rec));

@@ -444,15 +443,17 @@ static request_rec *internal_internal_redirect(const char *new_uri,
    ap_parse_uri(new, new_uri);

    new->request_config = ap_create_request_config(r->pool);
    req_cfg = apr_pcalloc(r->pool, sizeof(core_request_config));
    req_cfg->bb = apr_brigade_create(r->pool);
    ap_set_module_config(new->request_config, &core_module, req_cfg);

    new->per_dir_config = r->server->lookup_defaults;

    new->prev = r;
    r->next   = new;

    /* Must have prev and next pointers set before calling create_request
     * hook.
     */
    ap_run_create_request(new);

    /* Inherit the rest of the protocol info... */

    new->the_request = r->the_request;
+16 −0
Original line number Diff line number Diff line
@@ -3236,6 +3236,21 @@ static void core_insert_filter(request_rec *r)
    }
}

static void core_create_req(request_rec *r)
{
    if (r->main) {
        ap_set_module_config(r->request_config, &core_module,
              ap_get_module_config(r->main->request_config, &core_module));
    }
    else {
        core_request_config *req_cfg;

        req_cfg = apr_pcalloc(r->pool, sizeof(core_request_config));
        req_cfg->bb = apr_brigade_create(r->pool);
        ap_set_module_config(r->request_config, &core_module, req_cfg);
    }
}

static void register_hooks(apr_pool_t *p)
{
    ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
@@ -3245,6 +3260,7 @@ static void register_hooks(apr_pool_t *p)
    /* FIXME: I suspect we can eliminate the need for these - Ben */
    ap_hook_type_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
    ap_hook_access_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
    ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);

    /* register the core's insert_filter hook and register core-provided
     * filters
+1 −5
Original line number Diff line number Diff line
@@ -843,7 +843,6 @@ request_rec *ap_read_request(conn_rec *conn)
    apr_pool_t *p;
    const char *expect;
    int access_status;
    core_request_config *req_cfg;

    apr_pool_create(&p, conn->pool);
    r = apr_pcalloc(p, sizeof(request_rec));
@@ -866,10 +865,7 @@ request_rec *ap_read_request(conn_rec *conn)
    r->notes           = apr_table_make(r->pool, 5);

    r->request_config  = ap_create_request_config(r->pool);
    req_cfg = apr_pcalloc(r->pool, sizeof(core_request_config));
    req_cfg->bb = apr_brigade_create(r->pool);
    ap_set_module_config(r->request_config, &core_module, req_cfg);
                    
    ap_run_create_request(r);
    r->per_dir_config  = r->server->lookup_defaults;

    r->sent_bodyct     = 0;                      /* bytect isn't for body */
Loading