]> granicus.if.org Git - apache/commitdiff
Cleanup the proxy code that creates a request to the origin
authorRyan Bloom <rbb@apache.org>
Tue, 16 Oct 2001 05:18:39 +0000 (05:18 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 16 Oct 2001 05:18:39 +0000 (05:18 +0000)
server.  This change adds an optional hook, which allows modules
to gain control while the request is created if the proxy module
is loaded.  The purpose of this hook is to allow modules to add
input and/or output filters to the request to the origin.  While
I was at it, I made the core use this hook, so that proxy request
creation uses some of the code from the core.  This can still be
greatly improved, but this is a good start.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91486 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
configure.in
modules/proxy/mod_proxy.h
modules/proxy/proxy_util.c
server/core.c

diff --git a/CHANGES b/CHANGES
index bafbfb721e78351d909a7b18739612b04eb39cac..0872d99ffb7849021e43d8826368763dbca2742a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,14 @@
 Changes with Apache 2.0.27-dev
 
+  *) Cleanup the proxy code that creates a request to the origin
+     server.  This change adds an optional hook, which allows modules
+     to gain control while the request is created if the proxy module
+     is loaded.  The purpose of this hook is to allow modules to add
+     input and/or output filters to the request to the origin.  While
+     I was at it, I made the core use this hook, so that proxy request
+     creation uses some of the code from the core.  This can still be
+     greatly improved, but this is a good start.  [Ryan Bloom]
+
 Changes with Apache 2.0.26
 
   *) Port the MaxClients changes from the worker MPM to the threaded
index abbda853b6d1d09e102507ebd018a8770ba35e8f..de53272bbc8a39e8a2cd63159413d2ea54cdd601 100644 (file)
@@ -98,9 +98,9 @@ dnl then we are running in VPATH mode.
 
 if test "$abs_builddir" != "$abs_srcdir"; then
   USE_VPATH=1
-  APR_ADDTO(INCLUDES, [-I. -I\$(srcdir) -I\$(top_builddir)/os/\$(OS_DIR) -I\$(top_srcdir)/os/\$(OS_DIR) -I\$(top_builddir)/server/mpm/\$(MPM_NAME) -I\$(top_srcdir)/server/mpm/\$(MPM_NAME) -I\$(top_builddir)/modules/http -I\$(top_srcdir)/modules/http -I\$(top_builddir)/include -I\$(top_srcdir)/include -I\$(top_builddir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_builddir)/srclib/apr-util/include -I\$(top_srcdir)/srclib/apr-util/include])
+  APR_ADDTO(INCLUDES, [-I. -I\$(srcdir) -I\$(top_builddir)/os/\$(OS_DIR) -I\$(top_srcdir)/os/\$(OS_DIR) -I\$(top_builddir)/server/mpm/\$(MPM_NAME) -I\$(top_srcdir)/server/mpm/\$(MPM_NAME) -I\$(top_builddir)/modules/http -I\$(top_srcdir)/modules/http -I\$(top_srcdir)/modules/proxy -I\$(top_builddir)/include -I\$(top_srcdir)/include -I\$(top_builddir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_builddir)/srclib/apr-util/include -I\$(top_srcdir)/srclib/apr-util/include])
 else
-  APR_ADDTO(INCLUDES, [-I. -I\$(top_srcdir)/os/\$(OS_DIR) -I\$(top_srcdir)/server/mpm/\$(MPM_NAME) -I\$(top_srcdir)/modules/http -I\$(top_srcdir)/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr-util/include])
+  APR_ADDTO(INCLUDES, [-I. -I\$(top_srcdir)/os/\$(OS_DIR) -I\$(top_srcdir)/server/mpm/\$(MPM_NAME) -I\$(top_srcdir)/modules/http -I\$(top_srcdir)/modules/proxy -I\$(top_srcdir)/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr-util/include])
 fi
 
 echo $ac_n "${nl}Applying OS-specific hints for httpd ...${nl}"
index 7aa95d45840e5f5c05f438bba979e7d5ae728339..5b7a11d449d030852751b4035c47f01c2154d191 100644 (file)
@@ -237,6 +237,8 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r, 
                           char *url))
 
+APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
+
 /* proxy_util.c */
 
 PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
index 9dab21388f7a73ac33f600bf5906d1eca7c31217..3f4830268990f200df75fb7cd21871f5bd4ba39f 100644 (file)
@@ -65,6 +65,10 @@ static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
 static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
 static int proxy_match_word(struct dirconn_entry *This, request_rec *r);
 
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, AP, int, create_req, 
+                                   (request_rec *r, request_rec *pr), (r, pr),
+                                   OK, DECLINED)
+
 /* already called in the knowledge that the characters are hex digits */
 PROXY_DECLARE(int) ap_proxy_hex2c(const char *x)
 {
@@ -359,7 +363,6 @@ PROXY_DECLARE(const char *)
 PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r)
 {
     request_rec *rp = apr_pcalloc(c->pool, sizeof(*r));
-    core_request_config *req_cfg;
 
     rp->pool            = c->pool;
     rp->status          = HTTP_OK;
@@ -373,15 +376,11 @@ PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r)
     rp->server = r->server;
     rp->request_time = r->request_time;
     rp->connection      = c;
-    rp->output_filters=NULL;
-    rp->input_filters=NULL;
     rp->output_filters  = c->output_filters;
     rp->input_filters   = c->input_filters;
 
     rp->request_config  = ap_create_request_config(c->pool);
-    req_cfg = apr_pcalloc(rp->pool, sizeof(core_request_config));
-    req_cfg->bb = apr_brigade_create(c->pool);
-    ap_set_module_config(rp->request_config, &core_module, req_cfg);
+    proxy_run_create_req(r, rp);
 
     return rp;
 }
index cddac0942fd6935f683b9132b28f6a148750aaf9..65d2bacc08094a49be3ea9dc8f2c45403bb0bb19 100644 (file)
@@ -88,6 +88,7 @@
 #include "mpm_common.h"
 #include "scoreboard.h"
 #include "mod_core.h"
+#include "mod_proxy.h"
 
 
 /* LimitXMLRequestBody handling */
@@ -3230,6 +3231,11 @@ static int core_create_req(request_rec *r)
     return OK;
 }
 
+static int core_create_proxy_req(request_rec *r, request_rec *pr)
+{
+    core_create_req(pr);
+}
+
 static void register_hooks(apr_pool_t *p)
 {
     ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
@@ -3242,6 +3248,8 @@ static void register_hooks(apr_pool_t *p)
     ap_hook_fixups(core_override_type,NULL,NULL,APR_HOOK_REALLY_FIRST);
     ap_hook_access_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);
+    APR_OPTIONAL_HOOK(proxy, create_req, core_create_proxy_req, NULL, NULL, 
+                      APR_HOOK_MIDDLE);
     ap_hook_pre_mpm(ap_create_scoreboard, NULL, NULL, APR_HOOK_MIDDLE);
 
     /* register the core's insert_filter hook and register core-provided