From: Yann Ylavic Date: Thu, 3 Dec 2020 16:10:08 +0000 (+0000) Subject: mod_proxy_fcgi: follow up to r1884068 and r1884069. X-Git-Tag: 2.5.0-alpha2-ci-test-only~1115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11758dc66af7210469a3519bf99574b800fd25fd;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy_fcgi: follow up to r1884068 and r1884069. 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 --- diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c index 1a40553f007..3382b9bfd5c 100644 --- a/modules/proxy/mod_proxy_fcgi.c +++ b/modules/proxy/mod_proxy_fcgi.c @@ -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"); + } } }