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 61cd3a0..bf01c1b 100644
--- a/src/http_client.c
+++ b/src/http_client.c
@@ -792,11 +792,8 @@
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 @@
/* 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) {