Commit 12c80eba authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  Introduce the map_to_storage hook, which allows modules to bypass
  the directory_walk and file_walk for non-file requests.  TRACE
  shortcut moved to http_protocol.c as APR_HOOK_MIDDLE, and the
  directory_walk/file_walk happen as APR_HOOK_VERY_LAST in core.c.

  A seperate patch to mod_proxy is required to short circuit both the
  TRACE and directory_walk/file_walk stuff.  That patch is next.


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

  *) Introduce the map_to_storage hook, which allows modules to bypass
     the directory_walk and file_walk for non-file requests.  TRACE
     shortcut moved to http_protocol.c as APR_HOOK_MIDDLE, and the
     directory_walk/file_walk happen as APR_HOOK_VERY_LAST in core.c.
     [William Rowe]

  *) Add the ability for mod_include to add the INCLUDES filter
     if the file is configured for the server-parsed handler.
     This makes the configuration for .shtml files much easier
+18 −3
Original line number Diff line number Diff line
@@ -288,6 +288,21 @@ AP_DECLARE_HOOK(int,create_request,(request_rec *r))
 */
AP_DECLARE_HOOK(int,translate_name,(request_rec *r))

/**
 * This hook allow modules to set the per_dir_config based on their own
 * context (such as <Proxy > sections) and responds to contextless requests 
 * such as TRACE that need no security or filesystem mapping.
 * based on the filesystem.
 * @param r The current request
 * @return DONE (or HTTP_) if this contextless request was just fulfilled 
 * (such as TRACE), OK if this is not a file, and DECLINED if this is a file.
 * The core map_to_storage (HOOK_RUN_LAST) will directory_walk and file_walk
 * the r->filename.
 * 
 * @ingroup hooks
 */
AP_DECLARE_HOOK(int,map_to_storage,(request_rec *r))

/**
 * This hook allows modules to check the authentication information sent with
 * the request.
@@ -341,9 +356,9 @@ AP_DECLARE_HOOK(int,auth_checker,(request_rec *r))
 */
AP_DECLARE_HOOK(void,insert_filter,(request_rec *r))

AP_DECLARE(int) directory_walk(request_rec *r);
AP_DECLARE(int) location_walk(request_rec *r);
AP_DECLARE(int) file_walk(request_rec *r);
AP_DECLARE(int) ap_location_walk(request_rec *r);
AP_DECLARE(int) ap_directory_walk(request_rec *r);
AP_DECLARE(int) ap_file_walk(request_rec *r);

#ifdef __cplusplus
}
+1 −0
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ static void register_hooks(apr_pool_t *p)
			       APR_HOOK_REALLY_LAST);
    ap_hook_process_connection(ap_process_http_connection,NULL,NULL,
			       APR_HOOK_REALLY_LAST);
    ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE);
    ap_hook_http_method(http_method,NULL,NULL,APR_HOOK_REALLY_LAST);
    ap_hook_default_port(http_port,NULL,NULL,APR_HOOK_REALLY_LAST);

+5 −2
Original line number Diff line number Diff line
@@ -1023,12 +1023,15 @@ static char *make_allow(request_rec *r)
    return list + 2;
}

AP_DECLARE(int) ap_send_http_trace(request_rec *r)
AP_DECLARE_NONSTD(int) ap_send_http_trace(request_rec *r)
{
    int rv;
    apr_bucket_brigade *b;
    header_struct h;

    if (r->method_number != M_TRACE)
        return DECLINED;

    /* Get the original request */
    while (r->prev)
        r = r->prev;
@@ -1049,7 +1052,7 @@ AP_DECLARE(int) ap_send_http_trace(request_rec *r)
    apr_brigade_puts(b, NULL, NULL, CRLF);
    ap_pass_brigade(r->output_filters, b);

    return OK;
    return DONE;
}

AP_DECLARE(int) ap_send_http_options(request_rec *r)
+8 −32
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ static void process_request_internal(request_rec *r)

    ap_getparents(r->uri);     /* OK --- shrinking transformations... */

    if ((access_status = location_walk(r))) {
    if ((access_status = ap_location_walk(r))) {
        ap_die(access_status, r);
        return;
    }
@@ -263,40 +263,16 @@ static void process_request_internal(request_rec *r)
        return;
    }

    if (r->proto_num > HTTP_VERSION(1,0) && apr_table_get(r->subprocess_env, "downgrade-1.0")) {
        r->proto_num = HTTP_VERSION(1,0);
    }

    if (!r->proxyreq) {
	/*
	 * We don't want TRACE to run through the normal handler set, we
	 * handle it specially.
	 */
	if (r->method_number == M_TRACE) {
	    if ((access_status = ap_send_http_trace(r)))
		ap_die(access_status, r);
	    else
    if ((access_status = ap_run_map_to_storage(r))) {
        /* This request wasn't in storage (e.g. TRACE) */
        if (access_status == DONE)
	    ap_finalize_request_protocol(r);
	    return;
	}
    }

    /*
     * NB: directory_walk() clears the per_dir_config, so we don't inherit
     * from location_walk() above
     */

    if ((access_status = directory_walk(r))) {
        ap_die(access_status, r);
        return;
    }

    if ((access_status = file_walk(r))) {
	else
            ap_die(access_status, r);
        return;
    }

    if ((access_status = location_walk(r))) {
    if ((access_status = ap_location_walk(r))) {
        ap_die(access_status, r);
        return;
    }
Loading