From: Christopher Faulet Date: Wed, 1 Jun 2022 14:37:49 +0000 (+0200) Subject: BUG/MEDIUM: httpclient: Don't remove HTX header blocks before duplicating them X-Git-Tag: v2.7-dev1~122 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18de6f28809fc4228866e7717161692d54f31ce4;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: httpclient: Don't remove HTX header blocks before duplicating them Commit 534645d6 ("BUG/MEDIUM: httpclient: Fix loop consuming HTX blocks from the response channel") introduced a regression. When the response is consumed, The HTX header blocks are removed before duplicating them. Thus, the first header block is always lost. This patch must be backported as far as 2.5. --- diff --git a/src/http_client.c b/src/http_client.c index 61cd3a08c4..bf01c1b855 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -792,11 +792,8 @@ static void httpclient_applet_io_handler(struct appctx *appctx) uint32_t sz = htx_get_blksz(blk); c_rew(res, sz); - blk = htx_remove_blk(htx, blk); - if (type == HTX_BLK_UNUSED) - continue; - else if (type == HTX_BLK_HDR) { + if (type == HTX_BLK_HDR) { hdrs[hdr_num].n = istdup(htx_get_blk_name(htx, blk)); hdrs[hdr_num].v = istdup(htx_get_blk_value(htx, blk)); hdr_num++; @@ -805,8 +802,10 @@ static void httpclient_applet_io_handler(struct appctx *appctx) /* create a NULL end of array and leave the loop */ hdrs[hdr_num].n = IST_NULL; hdrs[hdr_num].v = IST_NULL; + htx_remove_blk(htx, blk); break; } + blk = htx_remove_blk(htx, blk); } if (hdr_num) {