]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_fcgi: follow up to r1884068 and r1884069.
authorYann Ylavic <ylavic@apache.org>
Thu, 3 Dec 2020 16:10:08 +0000 (16:10 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 3 Dec 2020 16:10:08 +0000 (16:10 +0000)
No mixed Transfer-Encoding and Content-Length possible.

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

modules/proxy/mod_proxy_fcgi.c

index 1a40553f007b0f3d3a877364da9f410c8a965db9..3382b9bfd5c837c0bbe6e7b9f3aff7cd3206676c 100644 (file)
@@ -1092,7 +1092,10 @@ static int proxy_fcgi_handler(request_rec *r, proxy_worker *worker,
     if (input_brigade == NULL) {
         const char *old_te = apr_table_get(r->headers_in, "Transfer-Encoding");
         const char *old_cl = NULL;
-        if (!old_te) {
+        if (old_te) {
+            apr_table_unset(r->headers_in, "Content-Length");
+        }
+        else {
             old_cl = apr_table_get(r->headers_in, "Content-Length");
         }
 
@@ -1140,8 +1143,8 @@ static int proxy_fcgi_handler(request_rec *r, proxy_worker *worker,
              * no body, do not set the Content-Length.
              */
             if (old_cl || old_te || input_bytes) {
-                apr_table_set(r->headers_in, "Content-Length",
-                              apr_off_t_toa(p, input_bytes));
+                apr_table_setn(r->headers_in, "Content-Length",
+                               apr_off_t_toa(p, input_bytes));
                 if (old_te) {
                     apr_table_unset(r->headers_in, "Transfer-Encoding");
                 }
@@ -1169,9 +1172,11 @@ static int proxy_fcgi_handler(request_rec *r, proxy_worker *worker,
             APR_BRIGADE_CONCAT(input_brigade, tmp_bb);
             input_bytes += remaining_bytes;
 
-            apr_table_unset(r->headers_in, "Transfer-Encoding");
-            apr_table_set(r->headers_in, "Content-Length",
-                          apr_off_t_toa(p, input_bytes));
+            apr_table_setn(r->headers_in, "Content-Length",
+                           apr_off_t_toa(p, input_bytes));
+            if (old_te) {
+                apr_table_unset(r->headers_in, "Transfer-Encoding");
+            }
         }
     }