]> granicus.if.org Git - apache/commitdiff
mod_proxy_http: handle 401 error override in the same block as other errors
authorYann Ylavic <ylavic@apache.org>
Tue, 2 Aug 2016 16:34:56 +0000 (16:34 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 2 Aug 2016 16:34:56 +0000 (16:34 +0000)
to simplify logic, no functional change.

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

modules/proxy/mod_proxy_http.c

index 2debfccfa1a979e0245de75590619303b3c28995..ff8157bb0eca98f954a6e52b4a35c774b03de673 100644 (file)
@@ -1606,20 +1606,20 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
          * ProxyPassReverse/etc from here to ap_proxy_read_headers
          */
 
-        if ((proxy_status == 401) && (dconf->error_override)) {
-            const char *buf;
-            const char *wa = "WWW-Authenticate";
-            if ((buf = apr_table_get(r->headers_out, wa))) {
-                apr_table_set(r->err_headers_out, wa, buf);
-            } else {
-                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01109)
-                              "origin server sent 401 without "
-                              "WWW-Authenticate header");
+        /* PR 41646: get HEAD right with ProxyErrorOverride */
+        if (ap_is_HTTP_ERROR(proxy_status) && dconf->error_override) {
+            if (proxy_status == HTTP_UNAUTHORIZED) {
+                const char *buf;
+                const char *wa = "WWW-Authenticate";
+                if ((buf = apr_table_get(r->headers_out, wa))) {
+                    apr_table_set(r->err_headers_out, wa, buf);
+                } else {
+                    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01109)
+                                  "origin server sent 401 without "
+                                  "WWW-Authenticate header");
+                }
             }
-        }
 
-        /* PR 41646: get HEAD right with ProxyErrorOverride */
-        if (ap_is_HTTP_ERROR(r->status) && dconf->error_override) {
             /* clear r->status for override error, otherwise ErrorDocument
              * thinks that this is a recursive error, and doesn't find the
              * custom error page