1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

New hook: ap_run_pre_read_request()

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1070616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Jagielski
2011-02-14 19:21:37 +00:00
parent ae4433b1f6
commit 9175224482
3 changed files with 43 additions and 6 deletions

View File

@@ -554,11 +554,24 @@ AP_DECLARE(int) ap_method_number_of(const char *method);
AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum); AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
/* Hooks */ /* Hooks */
/* /*
* post_read_request --- run right after read_request or internal_redirect, * pre_read_request --- run right before read_request_line(),
* and not run during any subrequests. * and not run during any subrequests.
*/ */
/**
* This hook allows modules to affect the request or connection immediately before
* the request has been read, and before any other phases have been processes.
* @param r The current request of the soon-to-be-read request
* @param c The connection
* @return None/void
*/
AP_DECLARE_HOOK(void,pre_read_request,(request_rec *r, conn_rec *c))
/*
* post_read_request --- run right after read_request or internal_redirect,
* and not run during any subrequests.
*/
/** /**
* This hook allows modules to affect the request immediately after the request * This hook allows modules to affect the request immediately after the request
* has been read, and before any other phases have been processes. This allows * has been read, and before any other phases have been processes. This allows
@@ -567,7 +580,7 @@ AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
* @return OK or DECLINED * @return OK or DECLINED
*/ */
AP_DECLARE_HOOK(int,post_read_request,(request_rec *r)) AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
/** /**
* This hook allows modules to perform any module-specific logging activities * This hook allows modules to perform any module-specific logging activities
* over and above the normal server things. * over and above the normal server things.

View File

@@ -1146,6 +1146,22 @@ static int x_process_connection(conn_rec *c)
return DECLINED; return DECLINED;
} }
/*
* This routine is called after the request has been read but before any other
* phases have been processed. This allows us to make decisions based upon
* the input header fields.
*
* This is a HOOK_VOID hook.
*/
void x_post_read_request(request_rec *r, conn_rec *c)
{
/*
* We don't actually *do* anything here, except note the fact that we were
* called.
*/
trace_request(r, "x_pre_read_request()");
}
/* /*
* This routine is called after the request has been read but before any other * This routine is called after the request has been read but before any other
* phases have been processed. This allows us to make decisions based upon * phases have been processed. This allows us to make decisions based upon
@@ -1449,6 +1465,8 @@ static void x_register_hooks(apr_pool_t *p)
ap_hook_quick_handler(x_quick_handler, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_quick_handler(x_quick_handler, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_pre_connection(x_pre_connection, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_pre_connection(x_pre_connection, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_process_connection(x_process_connection, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_process_connection(x_process_connection, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_pre_read_request(x_pre_read_request, NULL, NULL,
APR_HOOK_MIDDLE);
/* [1] post read_request handling */ /* [1] post read_request handling */
ap_hook_post_read_request(x_post_read_request, NULL, NULL, ap_hook_post_read_request(x_post_read_request, NULL, NULL,
APR_HOOK_MIDDLE); APR_HOOK_MIDDLE);

View File

@@ -60,6 +60,7 @@
APLOG_USE_MODULE(core); APLOG_USE_MODULE(core);
APR_HOOK_STRUCT( APR_HOOK_STRUCT(
APR_HOOK_LINK(pre_read_request)
APR_HOOK_LINK(post_read_request) APR_HOOK_LINK(post_read_request)
APR_HOOK_LINK(log_transaction) APR_HOOK_LINK(log_transaction)
APR_HOOK_LINK(http_scheme) APR_HOOK_LINK(http_scheme)
@@ -915,6 +916,8 @@ request_rec *ap_read_request(conn_rec *conn)
tmp_bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); tmp_bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
ap_run_pre_read_request(r, conn);
/* Get the request... */ /* Get the request... */
if (!read_request_line(r, tmp_bb)) { if (!read_request_line(r, tmp_bb)) {
if (r->status == HTTP_REQUEST_URI_TOO_LARGE if (r->status == HTTP_REQUEST_URI_TOO_LARGE
@@ -1733,6 +1736,9 @@ AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers)
} }
AP_IMPLEMENT_HOOK_VOID(pre_read_request,
(request_rec *r, conn_rec *c),
(r, c))
AP_IMPLEMENT_HOOK_RUN_ALL(int,post_read_request, AP_IMPLEMENT_HOOK_RUN_ALL(int,post_read_request,
(request_rec *r), (r), OK, DECLINED) (request_rec *r), (r), OK, DECLINED)
AP_IMPLEMENT_HOOK_RUN_ALL(int,log_transaction, AP_IMPLEMENT_HOOK_RUN_ALL(int,log_transaction,