From: Christopher Faulet Date: Wed, 6 Apr 2022 13:29:34 +0000 (+0200) Subject: BUG/MINOR: fcgi-app: Don't add C-L header on response to HEAD requests X-Git-Tag: v2.6-dev5~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d057960769f284e2e4ee9b38d3c99f28f656c71d;p=thirdparty%2Fhaproxy.git BUG/MINOR: fcgi-app: Don't add C-L header on response to HEAD requests In the FCGI app, when a full response is received, if there is no content-length and transfer-encoding headers, a content-length header is automatically added. This avoid, as far as possible to chunk the response. This trick was added because, most of time, scripts don"t add those headers. But this should not be performed for response to HEAD requests. Indeed, in this case, there is no payload. If the payload size is not specified, we must not added it by hand. Otherwise, a "content-length: 0" will always be added while it is not the real payload size (unknown at this stage). This patch should solve issue #1639. It must be backported as far as 2.2. --- diff --git a/src/fcgi-app.c b/src/fcgi-app.c index 8d180274a3..63e0bd2dd5 100644 --- a/src/fcgi-app.c +++ b/src/fcgi-app.c @@ -349,7 +349,7 @@ static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct /* Add the header "Content-Length:" if possible */ sl = http_get_stline(htx); - if (sl && + if (s->txn->meth != HTTP_METH_HEAD && sl && (sl->flags & (HTX_SL_F_XFER_LEN|HTX_SL_F_CLEN|HTX_SL_F_CHNK)) == HTX_SL_F_XFER_LEN && (htx->flags & HTX_FL_EOM)) { struct htx_blk * blk;