]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: httpclient: Don't remove HTX header blocks before duplicating them
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Jun 2022 14:37:49 +0000 (16:37 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Jun 2022 15:20:57 +0000 (17:20 +0200)
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

index 61cd3a08c4e33371546f0b09607828bac55a4dfd..bf01c1b8553d4a889c4b3f6af096625627b88397 100644 (file)
@@ -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) {