]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Revert r1480058, -1'ed on dev@ and STATUS.
authorYann Ylavic <ylavic@apache.org>
Thu, 10 Dec 2020 16:04:34 +0000 (16:04 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 10 Dec 2020 16:04:34 +0000 (16:04 +0000)
Never backported (and never will supposedly), while often creating
merge conflicts.

See https://lists.apache.org/thread.html/be0e7bdc3510fddd2dd80accece44917eba361ef4fcc713dd0f7f7fa%401367999236%40%3Cdev.httpd.apache.org%3E
and https://lists.apache.org/thread.html/6e63271b308a2723285d288857318e7bb51b6756690514d9bc75a71b%401371148914%40%3Ccvs.httpd.apache.org%3E

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

CHANGES
modules/proxy/mod_proxy_ftp.c
modules/proxy/mod_proxy_http.c
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index d232562583c595686aaef318223a6087e55960ae..a4a0aef93de5bd9c303b1f640b741a2aad74aa10 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -981,10 +981,6 @@ Changes with Apache 2.5.0-alpha
      clean mapping from APR codes to HTTP status codes, and use it where
      needed. [Graham Leggett]
 
-  *) mod_proxy: Ensure network errors detected by the proxy are returned as
-     504 Gateway Timeout as opposed to 502 Bad Gateway, in order to be
-     compliant with RFC2616 14.9.4 Cache Revalidation and Reload Controls.
-
   *) mod_dav: mod_dav overrides dav_fs response on PUT failure. PR 35981
      [Basant Kumar Kukreja <basant.kukreja sun.com>, Alejandro Alvarez
      <alejandro.alvarez.ayllon cern.ch>]
index 74eba0072d05d780732ab59997eacaf9b300cf91..77610e7df3a18fe747d7e31090f230101fe2a1f5 100644 (file)
@@ -869,11 +869,7 @@ static int ftp_set_TYPE(char xfer_type, request_rec *r, conn_rec *ftp_ctrl,
     /* 501 Syntax error in parameters or arguments. */
     /* 504 Command not implemented for that parameter. */
     /* 530 Not logged in. */
-    if (rc == -1) {
-        ret = ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
-                             "Error reading from remote server");
-    }
-    else if (rc == 421) {
+    if (rc == -1 || rc == 421) {
         ret = ap_proxyerror(r, HTTP_BAD_GATEWAY,
                              "Error reading from remote server");
     }
@@ -905,10 +901,6 @@ static char *ftp_get_PWD(request_rec *r, conn_rec *ftp_ctrl, apr_bucket_brigade
     /* 550 Requested action not taken. */
     switch (proxy_ftp_command("PWD" CRLF, r, ftp_ctrl, bb, &ftpmessage)) {
         case -1:
-            ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
-                             "Failed to read PWD on ftp server");
-            break;
-
         case 421:
         case 550:
             ap_proxyerror(r, HTTP_BAD_GATEWAY,
@@ -1164,7 +1156,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
      * them until we get a successful connection
      */
     if (APR_SUCCESS != err) {
-        return ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT, apr_pstrcat(p,
+        return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(p,
                                                  "DNS lookup failure for: ",
                                                         connectname, NULL));
     }
@@ -1235,15 +1227,10 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
     /* 220 Service ready for new user. */
     /* 421 Service not available, closing control connection. */
     rc = proxy_ftp_command(NULL, r, origin, bb, &ftpmessage);
-    if (rc == -1) {
-        return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                "Error reading from remote server");
-    }
-    else if (rc == 421) {
-        return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                "Error reading from remote server");
+    if (rc == -1 || rc == 421) {
+        return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, "Error reading from remote server");
     }
-    else if (rc == 120) {
+    if (rc == 120) {
         /*
          * RFC2616 states: 14.37 Retry-After
          *
@@ -1269,7 +1256,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         }
         return ftp_proxyerror(r, backend, HTTP_SERVICE_UNAVAILABLE, ftpmessage);
     }
-    else if (rc != 220) {
+    if (rc != 220) {
         return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
     }
 
@@ -1285,20 +1272,15 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
     /* (This may include errors such as command line too long.) */
     /* 501 Syntax error in parameters or arguments. */
     /* 530 Not logged in. */
-    if (rc == -1) {
-        return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                "Error reading from remote server");
-    }
-    else if (rc == 421) {
-        return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                "Error reading from remote server");
+    if (rc == -1 || rc == 421) {
+        return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, "Error reading from remote server");
     }
-    else if (rc == 530) {
+    if (rc == 530) {
         proxy_ftp_cleanup(r, backend);
         return ftp_unauthorized(r, 1);  /* log it: user name guessing
                                          * attempt? */
     }
-    else if (rc != 230 && rc != 331) {
+    if (rc != 230 && rc != 331) {
         return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
     }
 
@@ -1318,25 +1300,21 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         /* 501 Syntax error in parameters or arguments. */
         /* 503 Bad sequence of commands. */
         /* 530 Not logged in. */
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                                  "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
                                   "Error reading from remote server");
         }
-        else if (rc == 332) {
+        if (rc == 332) {
             return ftp_proxyerror(r, backend, HTTP_UNAUTHORIZED,
                   apr_pstrcat(p, "Need account for login: ", ftpmessage, NULL));
         }
         /* @@@ questionable -- we might as well return a 403 Forbidden here */
-        else if (rc == 530) {
+        if (rc == 530) {
             proxy_ftp_cleanup(r, backend);
             return ftp_unauthorized(r, 1);      /* log it: passwd guessing
                                                  * attempt? */
         }
-        else if (rc != 230 && rc != 202) {
+        if (rc != 230 && rc != 202) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
         }
     }
@@ -1352,14 +1330,9 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
             ++path;
 
         rc = proxy_ftp_command("CWD /" CRLF, r, origin, bb, &ftpmessage);
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421)
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
-        }
+                                  "Error reading from remote server");
     }
 
     /*
@@ -1396,18 +1369,14 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         /* 502 Command not implemented. */
         /* 530 Not logged in. */
         /* 550 Requested action not taken. */
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
+                                  "Error reading from remote server");
         }
-        else if (rc == 550) {
+        if (rc == 550) {
             return ftp_proxyerror(r, backend, HTTP_NOT_FOUND, ftpmessage);
         }
-        else if (rc != 250) {
+        if (rc != 250) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
         }
 
@@ -1441,15 +1410,11 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         /* 501 Syntax error in parameters or arguments. */
         /* 502 Command not implemented. */
         /* 530 Not logged in. */
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
+                                  "Error reading from remote server");
         }
-        else if (rc != 229 && rc != 500 && rc != 501 && rc != 502) {
+        if (rc != 229 && rc != 500 && rc != 501 && rc != 502) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
         }
         else if (rc == 229) {
@@ -1511,10 +1476,8 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01043)
                                   "EPSV attempt to connect to %pI failed - "
                                   "Firewall/NAT?", &epsv_addr);
-                    return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                            apr_psprintf(r->pool,
-                                    "EPSV attempt to connect to %pI failed - firewall/NAT?",
-                                    &epsv_addr));
+                    return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, apr_psprintf(r->pool,
+                                                                           "EPSV attempt to connect to %pI failed - firewall/NAT?", &epsv_addr));
                 }
                 else {
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
@@ -1536,15 +1499,11 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         /* 501 Syntax error in parameters or arguments. */
         /* 502 Command not implemented. */
         /* 530 Not logged in. */
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
+                                  "Error reading from remote server");
         }
-        else if (rc != 227 && rc != 502) {
+        if (rc != 227 && rc != 502) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
         }
         else if (rc == 227) {
@@ -1606,10 +1565,8 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                 if (rv != APR_SUCCESS) {
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01048)
                                   "PASV attempt to connect to %pI failed - Firewall/NAT?", pasv_addr);
-                    return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                            apr_psprintf(r->pool,
-                                    "PASV attempt to connect to %pI failed - firewall/NAT?",
-                                    pasv_addr));
+                    return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, apr_psprintf(r->pool,
+                                                                           "PASV attempt to connect to %pI failed - firewall/NAT?", pasv_addr));
                 }
                 else {
                     connect = 1;
@@ -1679,15 +1636,11 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
             /* 501 Syntax error in parameters or arguments. */
             /* 502 Command not implemented. */
             /* 530 Not logged in. */
-            if (rc == -1) {
-                return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                        "Error reading from remote server");
-            }
-            else if (rc == 421) {
+            if (rc == -1 || rc == 421) {
                 return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                        "Error reading from remote server");
+                                      "Error reading from remote server");
             }
-            else if (rc != 200) {
+            if (rc != 200) {
                 return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
             }
 
@@ -1748,13 +1701,9 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         rc = proxy_ftp_command(apr_pstrcat(p, "SIZE ",
                            ftp_escape_globbingchars(p, path, fdconf), CRLF, NULL),
                            r, origin, bb, &ftpmessage);
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
+                                  "Error reading from remote server");
         }
         else if (rc == 213) {/* Size command ok */
             int j;
@@ -1779,18 +1728,14 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
             /* 502 Command not implemented. */
             /* 530 Not logged in. */
             /* 550 Requested action not taken. */
-            if (rc == -1) {
-                return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                        "Error reading from remote server");
-            }
-            else if (rc == 421) {
+            if (rc == -1 || rc == 421) {
                 return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                        "Error reading from remote server");
+                                      "Error reading from remote server");
             }
-            else if (rc == 550) {
+            if (rc == 550) {
                 return ftp_proxyerror(r, backend, HTTP_NOT_FOUND, ftpmessage);
             }
-            else if (rc != 250) {
+            if (rc != 250) {
                 return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
             }
             path = "";
@@ -1897,15 +1842,11 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
     /* 501 Syntax error in parameters or arguments. */
     /* 530 Not logged in. */
     /* 550 Requested action not taken. */
-    if (rc == -1) {
-        return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                              "Error reading from remote server");
-    }
-    else if (rc == 421) {
+    if (rc == -1 || rc == 421) {
         return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
                               "Error reading from remote server");
     }
-    else if (rc == 550) {
+    if (rc == 550) {
         ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r,
                       "RETR failed, trying LIST instead");
 
@@ -1924,18 +1865,14 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
         /* 502 Command not implemented. */
         /* 530 Not logged in. */
         /* 550 Requested action not taken. */
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
+                                  "Error reading from remote server");
         }
-        else if (rc == 550) {
+        if (rc == 550) {
             return ftp_proxyerror(r, backend, HTTP_NOT_FOUND, ftpmessage);
         }
-        else if (rc != 250) {
+        if (rc != 250) {
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
         }
 
@@ -1951,14 +1888,9 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                                r, origin, bb, &ftpmessage);
 
         /* rc is an intermediate response for the LIST command (125 transfer starting, 150 opening data connection) */
-        if (rc == -1) {
-            return ftp_proxyerror(r, backend, HTTP_GATEWAY_TIME_OUT,
-                    "Error reading from remote server");
-        }
-        else if (rc == 421) {
+        if (rc == -1 || rc == 421)
             return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY,
-                    "Error reading from remote server");
-        }
+                                  "Error reading from remote server");
     }
     if (rc != 125 && rc != 150 && rc != 226 && rc != 250) {
         return ftp_proxyerror(r, backend, HTTP_BAD_GATEWAY, ftpmessage);
@@ -2030,7 +1962,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01053)
                               "failed to accept data connection");
                 proxy_ftp_cleanup(r, backend);
-                return HTTP_GATEWAY_TIME_OUT;
+                return HTTP_BAD_GATEWAY;
             }
         }
     }
index 751878cd8e2d2e06871fd4d714bcdd52eebf7799..c02e089f6701b7f690b3e66848d6688d4df09ba7 100644 (file)
@@ -1136,7 +1136,7 @@ int ap_proxy_http_process_response(proxy_http_req_t *req)
                               " Number of keepalives %i", backend->hostname,
                               backend->port, c->keepalives);
 
-                e = ap_bucket_error_create(HTTP_GATEWAY_TIME_OUT, NULL,
+                e = ap_bucket_error_create(HTTP_BAD_GATEWAY, NULL,
                         r->pool, c->bucket_alloc);
                 APR_BRIGADE_INSERT_TAIL(bb, e);
                 e = ap_bucket_eoc_create(c->bucket_alloc);
@@ -1154,7 +1154,7 @@ int ap_proxy_http_process_response(proxy_http_req_t *req)
                               " failed.",
                               backend->hostname, backend->port);
             }
-            return ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
+            return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                                  "Error reading from remote server");
         }
         /* XXX: Is this a real headers length send from remote? */
@@ -1686,7 +1686,7 @@ int ap_proxy_http_process_response(proxy_http_req_t *req)
                      * disconnect the client too.
                      */
                     apr_brigade_cleanup(bb);
-                    e = ap_bucket_error_create(HTTP_GATEWAY_TIME_OUT, NULL,
+                    e = ap_bucket_error_create(HTTP_BAD_GATEWAY, NULL,
                             r->pool, c->bucket_alloc);
                     APR_BRIGADE_INSERT_TAIL(bb, e);
                     e = ap_bucket_eoc_create(c->bucket_alloc);
index a699201610bb4d0a105c21cd588f02b8d6c53191..db9ccf5cdfcde501c50f2afcd7e4c969532da9ff 100644 (file)
@@ -2639,7 +2639,7 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
     }
 
     if (err != APR_SUCCESS) {
-        return ap_proxyerror(r, HTTP_GATEWAY_TIME_OUT,
+        return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                              apr_pstrcat(p, "DNS lookup failure for: ",
                                          conn->hostname, NULL));
     }
@@ -3461,7 +3461,7 @@ PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
      */
     if (r->main)
         r->main->no_cache = 1;
-    e = ap_bucket_error_create(HTTP_GATEWAY_TIME_OUT, NULL, c->pool,
+    e = ap_bucket_error_create(HTTP_BAD_GATEWAY, NULL, c->pool,
                                c->bucket_alloc);
     APR_BRIGADE_INSERT_TAIL(brigade, e);
     e = apr_bucket_eos_create(c->bucket_alloc);
@@ -4294,7 +4294,8 @@ PROXY_DECLARE(int) ap_proxy_pass_brigade(apr_bucket_alloc_t *bucket_alloc,
                                      "Error during SSL Handshake with"
                                      " remote server");
             }
-            return HTTP_GATEWAY_TIME_OUT;
+            return APR_STATUS_IS_TIMEUP(status) ? HTTP_GATEWAY_TIME_OUT
+                                                : HTTP_BAD_GATEWAY;
         }
         else {
             return HTTP_BAD_REQUEST;