[PATCH] mod_proxy handling of chunked requests

Mathias Herberts <[email protected]> Tue, 11 Mar 2003 15:13:55 +0100
Newsgroups gmane.comp.apache.mod-proxy
Message-ID <[email protected]>
Here is my second shot of a patch solving the issue of requests sent 
using 'Transfer-Encoding: chunked' and handled by mod_proxy in Apache 
1.3.27. Basically it changes mod_proxy behavior from 
REQUEST_CHUNKED_ERROR to REQUEST_CHUNKED_PASS, meaning requests sent 
using chunked transfer encoding will be passed as is to the origin server.

This patch is minimal and does not modify the behavior of mod_proxy for 
non chunked requests, it issues an additional 'Transfer-Encoding: 
chunked' when the request used one.

Please provide any feedback.

Mathias.

-- 
--  Informatique du Credit Mutuel  ----  Reseaux et Systemes Distribues
--  32 rue Mirabeau -- Le Relecq-Kerhuon -- 29808 Brest Cedex 9, FRANCE
--  Tel +33298004653 - Fax +33298284005 - Mail [email protected]
--  Key Fingerprint: 8778 D2FD 3B4A 6B33 10AB  F503 63D0 ADAE 9112 03E4
GICMApache-mod_proxy-chunked-requests.patch (text/plain, 987 B)
--- apache_1.3.27/src/modules/proxy/proxy_http.c.orig	Mon Mar 10 15:36:43 2003
+++ apache_1.3.27/src/modules/proxy/proxy_http.c	Tue Mar 11 10:56:13 2003
@@ -404,6 +404,14 @@
         ap_bvputs(f, reqhdrs_elts[i].key, ": ", reqhdrs_elts[i].val, CRLF, NULL);
     }
 
+    /*
+     * Output a Transfer-Encoding: chunked header if request used it.
+     */
+
+    if (r->read_chunked) {
+      ap_bvputs(f, "Transfer-Encoding: chunked", CRLF, NULL);
+    }
+
     /* the obligatory empty line to mark the end of the headers */
     ap_bputs(CRLF, f);
 
--- apache_1.3.27/src/modules/proxy/mod_proxy.c.orig	Mon Mar 10 15:36:48 2003
+++ apache_1.3.27/src/modules/proxy/mod_proxy.c	Mon Mar 10 15:39:16 2003
@@ -319,7 +319,7 @@
                 ap_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd - 1 : 0));
     }
 
-    if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
+    if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_PASS)))
         return rc;
 
     url = r->filename + 6;
smime.p7s (application/x-pkcs7-signature, 3.5 KB) - not displayed