| Add hooks to the scheme processing to allow other modules to
| recognize more schemes by intercepting this processing.
+---------------------------------------------------------------------------
-Index: src/modules/proxy/mod_proxy.c
---- src/modules/proxy/mod_proxy.c 18 Jul 2003 15:44:36 -0000 1.1.1.13
-+++ src/modules/proxy/mod_proxy.c 18 Jul 2003 15:56:58 -0000 1.20
-@@ -218,6 +218,9 @@
- static int proxy_fixup(request_rec *r)
- {
- char *url, *p;
-+#ifdef EAPI
-+ int rc;
-+#endif /* EAPI */
-
- if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
- return DECLINED;
-@@ -225,6 +228,14 @@
- url = &r->filename[6];
-
- /* canonicalise each specific scheme */
-+#ifdef EAPI
-+ if (ap_hook_use("ap::mod_proxy::canon",
-+ AP_HOOK_SIG3(int,ptr,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, url) && rc != DECLINED)
-+ return rc;
-+ else
-+#endif /* EAPI */
- if (strncasecmp(url, "http:", 5) == 0)
- return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
- else if (strncasecmp(url, "ftp:", 4) == 0)
-@@ -240,9 +251,44 @@
- static void proxy_init(server_rec *r, pool *p)
- {
- ap_proxy_garbage_init(r, p);
-+#ifdef EAPI
-+ ap_hook_use("ap::mod_proxy::init",
-+ AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
-+#endif
- }
-
--
-+#ifdef EAPI
-+static void proxy_addmod(module *m)
-+{
-+ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
-+ ap_hook_configure("ap::mod_proxy::http::canon",
-+ AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_register("ap::mod_proxy::http::canon",
-+ ap_proxy_http_canon, AP_HOOK_NOCTX);
-+
-+ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
-+ ap_hook_configure("ap::mod_proxy::http::handler",
-+ AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
-+ ap_hook_register("ap::mod_proxy::http::handler",
-+ ap_proxy_http_handler, AP_HOOK_NOCTX);
-+
-+ /* export: ap_proxyerror() as `ap::mod_proxy::error' */
-+ ap_hook_configure("ap::mod_proxy::error",
-+ AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
-+ ap_hook_register("ap::mod_proxy::error",
-+ ap_proxyerror, AP_HOOK_NOCTX);
-+ return;
-+}
-+
-+static void proxy_remmod(module *m)
-+{
-+ /* remove the hook references */
-+ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
-+ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
-+ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
-+ return;
-+}
-+#endif /* EAPI */
-
- /* Send a redirection if the request contains a hostname which is not */
- /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
-@@ -374,6 +420,14 @@
- * CONNECT is a special method that bypasses the normal proxy
- * code.
- */
-+#ifdef EAPI
-+ if (!ap_hook_use("ap::mod_proxy::handler",
-+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, cr, url,
-+ ents[i].hostname, ents[i].port,
-+ ents[i].protocol) || rc == DECLINED) {
-+#endif /* EAPI */
- if (r->method_number == M_CONNECT)
- rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
- ents[i].port);
-@@ -383,6 +437,9 @@
- ents[i].port);
- else
- rc = DECLINED;
-+#ifdef EAPI
-+ }
-+#endif /* EAPI */
-
- /* an error or success */
- if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
-@@ -397,6 +454,14 @@
- */
-
- /* handle the scheme */
-+#ifdef EAPI
-+ if (ap_hook_use("ap::mod_proxy::handler",
-+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, cr, url,
-+ NULL, 0, scheme) && rc != DECLINED)
-+ return rc;
-+#endif /* EAPI */
- if (r->method_number == M_CONNECT) {
- return ap_proxy_connect_handler(r, cr, url, NULL, 0);
- }
-@@ -994,4 +1059,10 @@
- NULL, /* child_init */
- NULL, /* child_exit */
- proxy_detect /* post read-request */
-+#ifdef EAPI
-+ ,proxy_addmod, /* EAPI: add_module */
-+ proxy_remmod, /* EAPI: remove_module */
-+ NULL, /* EAPI: rewrite_command */
-+ NULL /* EAPI: new_connection */
-+#endif
- };
-
-+---------------------------------------------------------------------------
-| Add hooks to the HTTP processing to allow other modules
-| to enhance it by intercepting this processing.
-+---------------------------------------------------------------------------
-Index: src/modules/proxy/proxy_http.c
---- src/modules/proxy/proxy_http.c 18 Jul 2003 15:44:37 -0000 1.1.1.16
-+++ src/modules/proxy/proxy_http.c 18 Jul 2003 15:56:58 -0000 1.24
-@@ -170,6 +170,9 @@
- const char *datestr, *urlstr;
- int result, major, minor;
- const char *content_length;
-+#ifdef EAPI
-+ char *peer;
-+#endif
-
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
-@@ -191,6 +194,12 @@
- return HTTP_BAD_REQUEST;
- urlptr += 3;
- destport = DEFAULT_HTTP_PORT;
-+#ifdef EAPI
-+ ap_hook_use("ap::mod_proxy::http::handler::set_destport",
-+ AP_HOOK_SIG2(int,ptr),
-+ AP_HOOK_TOPMOST,
-+ &destport, r);
-+#endif /* EAPI */
- strp = strchr(urlptr, '/');
- if (strp == NULL) {
- desthost = ap_pstrdup(p, urlptr);
-@@ -228,12 +237,18 @@
- err = ap_proxy_host2addr(proxyhost, &server_hp);
- if (err != NULL)
- return DECLINED; /* try another */
-+#ifdef EAPI
-+ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);
-+#endif
- }
- else {
- server.sin_port = htons((unsigned short)destport);
- err = ap_proxy_host2addr(desthost, &server_hp);
- if (err != NULL)
- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
-+#ifdef EAPI
-+ peer = ap_psprintf(p, "%s:%u", desthost, destport);
-+#endif
- }
-
-
-@@ -308,14 +323,42 @@
- f = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(f, sock, sock);
-
-+#ifdef EAPI
-+ {
-+ char *errmsg = NULL;
-+ ap_hook_use("ap::mod_proxy::http::handler::new_connection",
-+ AP_HOOK_SIG4(ptr,ptr,ptr,ptr),
-+ AP_HOOK_DECLINE(NULL),
-+ &errmsg, r, f, peer);
-+ if (errmsg != NULL)
-+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
-+ }
-+#endif /* EAPI */
-+
- ap_hard_timeout("proxy send", r);
- ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
- NULL);
-+#ifdef EAPI
-+ {
-+ int rc = DECLINED;
-+ ap_hook_use("ap::mod_proxy::http::handler::write_host_header",
-+ AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr),
-+ AP_HOOK_DECLINE(DECLINED),
-+ &rc, r, f, desthost, destport, destportstr);
-+ if (rc == DECLINED) {
-+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
-+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
-+ else
-+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
-+ }
-+ }
-+#else /* EAPI */
- /* Send Host: now, adding it to req_hdrs wouldn't be much better */
- if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
- ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
- else
- ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
-+#endif /* EAPI */
-
- if (conf->viaopt == via_block) {
- /* Block all outgoing Via: headers */
+---------------------------------------------------------------------------
| Add EAPI hooks in module structure for APXS generated samples.