I've attached patches for both trunk and 2.0.x. I was unable to
confirm that the trunk change drops the backend connection, probably
because of a basic user error when testing*. No issues verifying that
with 2.0 though.
*if the existing code earlier in the function to drop the backend
connection works, then this should too ;)
Index: modules/proxy/proxy_http.c
===================================================================
--- modules/proxy/proxy_http.c (revision 193172)
+++ modules/proxy/proxy_http.c (working copy)
@@ -1201,8 +1201,24 @@
return r->status;
} else {
+ const char *buf;
+
+ /* can't have both Content-Length and Transfer-Encoding */
+ if (apr_table_get(r->headers_out, "Transfer-Encoding")
+ && apr_table_get(r->headers_out, "Content-Length")) {
+ /* 2616 section 4.4, point 3: "if both Transfer-Encoding
+ * and Content-Length are received, the latter MUST be
+ * ignored"; so unset it here to prevent any confusion
+ * later. */
+ apr_table_unset(r->headers_out, "Content-Length");
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,
+ r->server,
+ "proxy: server %s returned Transfer-Encoding
and Content-Length",
+ p_conn->name);
+ p_conn->close += 1;
+ }
+
/* strip connection listed hop-by-hop headers from response */
- const char *buf;
p_conn->close += ap_proxy_liststr(apr_table_get(r->headers_out,
"Connection"),
"close");
Index: modules/proxy/mod_proxy_http.c
===================================================================
--- modules/proxy/mod_proxy_http.c (revision 193129)
+++ modules/proxy/mod_proxy_http.c (working copy)
@@ -1128,7 +1128,22 @@
r->headers_out,
save_table);
}
-
+
+ /* can't have both Content-Length and Transfer-Encoding */
+ if (apr_table_get(r->headers_out, "Transfer-Encoding")
+ && apr_table_get(r->headers_out, "Content-Length")) {
+ /* 2616 section 4.4, point 3: "if both Transfer-Encoding
+ * and Content-Length are received, the latter MUST be
+ * ignored"; so unset it here to prevent any confusion
+ * later. */
+ apr_table_unset(r->headers_out, "Content-Length");
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,
+ r->server,
+ "proxy: server %s returned Transfer-Encoding
and Content-Length",
+ backend->hostname);
+ backend->close += 1;
+ }
+
/* strip connection listed hop-by-hop headers from response */
backend->close +=
ap_proxy_liststr(apr_table_get(r->headers_out,
"Connection"),