Commit 88b9a1fa authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

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
parent e68377ad
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -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 ]
+17 −0
Original line number Diff line number Diff line
@@ -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 */