httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1070616 - in /httpd/httpd/trunk: include/http_protocol.h modules/examples/mod_example_hooks.c server/protocol.c
Date Mon, 14 Feb 2011 19:21:37 GMT
Author: jim
Date: Mon Feb 14 19:21:37 2011
New Revision: 1070616

URL: http://svn.apache.org/viewvc?rev=1070616&view=rev
Log:
New hook: ap_run_pre_read_request()

Modified:
    httpd/httpd/trunk/include/http_protocol.h
    httpd/httpd/trunk/modules/examples/mod_example_hooks.c
    httpd/httpd/trunk/server/protocol.c

Modified: httpd/httpd/trunk/include/http_protocol.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_protocol.h?rev=1070616&r1=1070615&r2=1070616&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_protocol.h (original)
+++ httpd/httpd/trunk/include/http_protocol.h Mon Feb 14 19:21:37 2011
@@ -554,11 +554,24 @@ AP_DECLARE(int) ap_method_number_of(cons
 AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum);
 
 
-  /* Hooks */
-  /*
-   * post_read_request --- run right after read_request or internal_redirect,
-   *                  and not run during any subrequests.
-   */
+/* Hooks */
+/*
+ * pre_read_request --- run right before read_request_line(),
+ *                  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
  * has been read, and before any other phases have been processes.  This allows
@@ -567,7 +580,7 @@ AP_DECLARE(const char *) ap_method_name_
  * @return OK or DECLINED
  */
 AP_DECLARE_HOOK(int,post_read_request,(request_rec *r))
-
+    
 /**
  * This hook allows modules to perform any module-specific logging activities
  * over and above the normal server things.

Modified: httpd/httpd/trunk/modules/examples/mod_example_hooks.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_example_hooks.c?rev=1070616&r1=1070615&r2=1070616&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/examples/mod_example_hooks.c (original)
+++ httpd/httpd/trunk/modules/examples/mod_example_hooks.c Mon Feb 14 19:21:37 2011
@@ -1151,6 +1151,22 @@ static int x_process_connection(conn_rec
  * 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
+ * phases have been processed.  This allows us to make decisions based upon
+ * the input header fields.
+ *
  * This is a RUN_ALL hook.
  */
 static int x_post_read_request(request_rec *r)
@@ -1449,6 +1465,8 @@ static void x_register_hooks(apr_pool_t 
     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_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 */
     ap_hook_post_read_request(x_post_read_request, NULL, NULL,
                               APR_HOOK_MIDDLE);

Modified: httpd/httpd/trunk/server/protocol.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/protocol.c?rev=1070616&r1=1070615&r2=1070616&view=diff
==============================================================================
--- httpd/httpd/trunk/server/protocol.c (original)
+++ httpd/httpd/trunk/server/protocol.c Mon Feb 14 19:21:37 2011
@@ -60,6 +60,7 @@
 APLOG_USE_MODULE(core);
 
 APR_HOOK_STRUCT(
+    APR_HOOK_LINK(pre_read_request)
     APR_HOOK_LINK(post_read_request)
     APR_HOOK_LINK(log_transaction)
     APR_HOOK_LINK(http_scheme)
@@ -915,6 +916,8 @@ request_rec *ap_read_request(conn_rec *c
 
     tmp_bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
 
+    ap_run_pre_read_request(r, conn);
+    
     /* Get the request... */
     if (!read_request_line(r, tmp_bb)) {
         if (r->status == HTTP_REQUEST_URI_TOO_LARGE
@@ -1733,6 +1736,9 @@ AP_DECLARE(void) ap_send_interim_respons
 }
 
 
+AP_IMPLEMENT_HOOK_VOID(pre_read_request,
+                       (request_rec *r, conn_rec *c),
+                       (r, c))
 AP_IMPLEMENT_HOOK_RUN_ALL(int,post_read_request,
                           (request_rec *r), (r), OK, DECLINED)
 AP_IMPLEMENT_HOOK_RUN_ALL(int,log_transaction,



Mime
View raw message