From: William A. Rowe Jr Date: Thu, 30 Jun 2016 17:14:18 +0000 (+0000) Subject: mod_proxy: Give ap_proxy_post_request as chance to act correctly on the status X-Git-Tag: 2.2.32~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca8260ccfc8548863918fc6e83b50171d6984feb;p=thirdparty%2Fapache%2Fhttpd.git 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. 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 --- diff --git a/STATUS b/STATUS index aaf1dafb869..b9861d2519a 100644 --- 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 ] diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 6a484902ce2..4e91e656ed6 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -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 */