]> granicus.if.org Git - apache/commitdiff
This patch adds a new hook (request_status) that gets ran in proxy_handler
authorIan Holsman <ianh@apache.org>
Sun, 17 Jul 2005 05:12:10 +0000 (05:12 +0000)
committerIan Holsman <ianh@apache.org>
Sun, 17 Jul 2005 05:12:10 +0000 (05:12 +0000)
just before the final return.  This gives modules an opportunity to do
something based on the proxy status.

A couple of examples where this is useful:

-You are using a caching module and would rather return stale content rather
than an error to the client if the origin is down.

-you proxy some subrequests (using SSI - mod_include) and do not want SSI
errors when the backend is down. If you would normally return
HTTP_BAD_GATEWAY, you may have a module that serves some other content.

new hook -- so mmn bump.. i made it a major one, hope thats ok

Patch From Brian Akins <Brian.Akins turner.com>

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

CHANGES
include/ap_mmn.h
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h

diff --git a/CHANGES b/CHANGES
index e9c47a2e5d14674b5781d724df68fe4a8b7b841d..c157e8929240cd488cab1cb45b1f4c5d557ef643 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,10 @@
 Changes with Apache 2.1.7
   [Remove entries to the current 2.0 section below, when backported]
+  
+  *)  new hook (request_status) that gets ran in proxy_handler just before 
+      the final return.  This gives modules an opportunity to do something 
+      based on the proxy status. (major MMN bump)
+      [Brian Akins <bakins turner.com>, Ian Holsman]
 
   *) SECURITY: CAN-2005-2088
      proxy: Correctly handle the Transfer-Encoding and Content-Length
index 67f1ef61abf7cbb1c87da8c555f66bd193f36f34..259ba397f2477ead15858a6acf41e7c38e999025 100644 (file)
  * 20050701.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP21"!
  * 20050701.1 (2.1.7-dev) trace_enable member added to core server_config
  * 20050708.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP22"!
+ * 20050717.0 (2.1.7-dev) add proxy request_status hook
   */
 
 #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20050708
+#define MODULE_MAGIC_NUMBER_MAJOR 20050717
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 
index 791de75ebb3f1b79fc0c71421124fe185c75de27..2fd69f8ac897d5f357fdb04791c60bb98c792bca 100644 (file)
@@ -732,9 +732,12 @@ cleanup:
         int post_status = proxy_run_post_request(worker, balancer, r, conf);
         if (post_status == DECLINED) {
             post_status = OK; /* no post_request handler available */
-            /* TODO: reclycle direct worker */
+            /* TODO: recycle direct worker */
         }
     }
+
+    proxy_run_request_status(&access_status, r);
+
     return access_status;
 }
 
@@ -1881,6 +1884,7 @@ APR_HOOK_STRUCT(
     APR_HOOK_LINK(canon_handler)
     APR_HOOK_LINK(pre_request)
     APR_HOOK_LINK(post_request)
+    APR_HOOK_LINK(request_status)
 )
 
 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, scheme_handler, 
@@ -1908,3 +1912,7 @@ APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, post_request,
 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, fixups,
                                     (request_rec *r), (r),
                                     OK, DECLINED)
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, request_status,
+                                    (int *status, request_rec *r), 
+                                    (status, r),
+                                    OK, DECLINED)
index 8ea9e2b409a743343d68d31bf8856761d8745f20..5f8ec9511a68d34da5d243ffec630f9672155886 100644 (file)
@@ -375,6 +375,13 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker
                           proxy_balancer *balancer, request_rec *r,
                           proxy_server_conf *conf))
 
+/**
+ * request status hook
+ * It is called after all proxy processing has been done.  This gives other
+ * modules a chance to create default content on failure, for example
+ */
+APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
+                          (int *status, request_rec *r))
 
 /* proxy_util.c */
 
@@ -541,6 +548,14 @@ PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
                                          proxy_balancer *balancer,
                                          request_rec *r,
                                          proxy_server_conf *conf);
+
+/**
+ * Request status function
+ * @param status   status of proxy request
+ * @return         OK or DECLINED
+ */
+ PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
+
 /**
  * Deternime backend hostname and port
  * @param p       memory pool used for processing