From 18de6f28809fc4228866e7717161692d54f31ce4 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 1 Jun 2022 16:37:49 +0200 Subject: [PATCH] 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. --- src/http_client.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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) { -- 2.47.3