]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r631735 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 27 May 2008 16:21:14 +0000 (16:21 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 27 May 2008 16:21:14 +0000 (16:21 +0000)
* Do not retry a direct connection if the request has a request body

Submitted by: rpluem
Reviewed by: jim

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

CHANGES
STATUS
modules/proxy/mod_proxy.c

diff --git a/CHANGES b/CHANGES
index 969cd0b99798537ed40866cf65342aa4782632b2..b316b71e993d95ec2018e99ed547126ce50e07b6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.2.9
 
+  *) mod_proxy: Do not try a direct connection if the connection via a
+     remote proxy failed before and the request has a request body.
+     [Ruediger Pluem]
+
   *) mod_proxy_ajp: Do not retry request in the case that we either failed to
      sent a part of the request body or if the request is not idempotent.
      PR 44334 [Ruediger Pluem]
diff --git a/STATUS b/STATUS
index cb2b88c22829a99fba4223c2aa1fe4ae8c0ec56c..57f5cef16dd724bbfb1898678e7d6b4bf0e92d0e 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -90,14 +90,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
- * mod_proxy: Do not try a direct connection if the connection via a
-   remote proxy failed before and the request has a request body.
-   Trunk version of patch:
-         http://svn.apache.org/viewvc?rev=631735&view=rev
-   Backport version for 2.2.x of patch:
-         Trunk version of patch works
-   +1: rpluem, niq, jim
-
  * mod_cache: Handle If-Range correctly if the cached resource was stale.
    PR 44579
    Trunk version of patch:
index 06c8b3384de970faa782cfe00d8b5e8efbf0f9b8..4ead5e9e0cf143a1305b1d7d28e58cb48c915f09 100644 (file)
@@ -839,12 +839,41 @@ static int proxy_handler(request_rec *r)
                                                              ents[i].hostname,
                                                              ents[i].port);
 
-                    /* an error or success */
-                    if (access_status != DECLINED &&
-                        access_status != HTTP_BAD_GATEWAY) {
-                        goto cleanup;
+                    /* Did the scheme handler process the request? */
+                    if (access_status != DECLINED) {
+                        const char *cl_a;
+                        char *end;
+                        apr_off_t cl;
+
+                        /*
+                         * An fatal error or success, so no point in
+                         * retrying with a direct connection.
+                         */
+                        if (access_status != HTTP_BAD_GATEWAY) {
+                            goto cleanup;
+                        }
+                        cl_a = apr_table_get(r->headers_in, "Content-Length");
+                        if (cl_a) {
+                            apr_strtoff(&cl, cl_a, &end, 0);
+                            /*
+                             * The request body is of length > 0. We cannot
+                             * retry with a direct connection since we already
+                             * sent (parts of) the request body to the proxy
+                             * and do not have any longer.
+                             */
+                            if (cl > 0) {
+                                goto cleanup;
+                            }
+                        }
+                        /*
+                         * Transfer-Encoding was set as input header, so we had
+                         * a request body. We cannot retry with a direct
+                         * connection for the same reason as above.
+                         */
+                        if (apr_table_get(r->headers_in, "Transfer-Encoding")) {
+                            goto cleanup;
+                        }
                     }
-                    /* we failed to talk to the upstream proxy */
                 }
             }
         }