From: Jim Jagielski Date: Tue, 27 May 2008 16:21:14 +0000 (+0000) Subject: Merge r631735 from trunk: X-Git-Tag: 2.2.9~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe73f158f61325b5db1a2f02a21d405ed6f4cc72;p=thirdparty%2Fapache%2Fhttpd.git Merge r631735 from trunk: * 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 --- diff --git a/CHANGES b/CHANGES index 969cd0b9979..b316b71e993 100644 --- 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 cb2b88c2282..57f5cef16dd 100644 --- 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: diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 06c8b3384de..4ead5e9e0cf 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -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 */ } } }