]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy: Give ap_proxy_post_request as chance to act correctly on the status
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Jun 2016 17:14:18 +0000 (17:14 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Jun 2016 17:14:18 +0000 (17:14 +0000)
code by setting r->status temporarily to access_status. r->status might be
different than access_status e.g. r->status could be HTTP_OK if e.g. we
override the error page on the proxy or if the error was not generated by the
backend itself but by the proxy e.g. a bad gateway.

Backports: r1597352
Submitted by: rpluem
Reviewed by: wrowe, ylavic

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1750838 13f79535-47bb-0310-9956-ffa450edef68

STATUS
modules/proxy/mod_proxy.c

diff --git a/STATUS b/STATUS
index aaf1dafb8695d12abacf537ff3f71b7a24266f50..b9861d2519af70e331b063a8e8a9626dfcecdce3 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -119,17 +119,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
       2.2.x patch: http://people.apache.org/~rpluem/patches/proxy-dns-patch_2.2.x.diff
       +1: rpluem, wrowe, ylavic
 
-  *) mod_proxy: Give ap_proxy_post_request as chance to act correctly on the status code
-     by setting r->status temporarily to access_status. r->status might be different than
-     access_status e.g. r->status could be HTTP_OK if e.g. we override the error page on
-     the proxy or if the error was not generated by the backend itself but by the proxy
-     e.g. a bad gateway.
-     Trunk version of patch:
-        http://svn.apache.org/r1597352
-     Backport version for 2.2.x of patch:
-        http://people.apache.org/~rpluem/patches/proxy_post_request_status_code.diff
-     +1: rpluem, wrowe, ylavic
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 6a484902ce29a2e1c03325e64d17c8e61b12d5de..4e91e656ed69e9670d1a1e1fb4b31d70ae729273 100644 (file)
@@ -837,6 +837,7 @@ static int proxy_handler(request_rec *r)
     proxy_worker *worker = NULL;
     int attempts = 0, max_attempts = 0;
     struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts;
+    int saved_status;
 
     /* is this for us? */
     if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0)
@@ -1080,7 +1081,23 @@ static int proxy_handler(request_rec *r)
     }
 cleanup:
     if (balancer) {
+        /*
+         * Save current r->status and set it to the value of access_status which
+         * might be different (e.g. r->status could be HTTP_OK if e.g. we override
+         * the error page on the proxy or if the error was not generated by the
+         * backend itself but by the proxy e.g. a bad gateway) in order to give
+         * ap_proxy_post_request a chance to act correctly on the status code.
+         */
+        saved_status = r->status;
+        r->status = access_status;
         int post_status = proxy_run_post_request(worker, balancer, r, conf);
+        /*
+         * Only restore r->status if it has not been changed by
+         * ap_proxy_post_request as we assume that this change was intentional.
+         */
+        if (r->status == access_status) {
+            r->status = saved_status;
+        }
         if (post_status == DECLINED) {
             post_status = OK; /* no post_request handler available */
             /* TODO: recycle direct worker */