]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: fcgi-app: Stop on last HTX block when getting the payload size
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Jul 2026 15:12:27 +0000 (17:12 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Jul 2026 10:20:47 +0000 (12:20 +0200)
In the loop counting all DATA block to be able to add a "Content-length:"
header in the FCGI response, we now check flags on the HTX block to know if
it is the last one of the message or not. If HTX_BLK_FL_EOM flag is set, it
means we can stop.

src/fcgi-app.c

index 479b1d8012b86d0ba33783a803b84b450d1feb22..81a9a4bec98f46f93ffdb85c9a11ff2b25d5374c 100644 (file)
@@ -346,10 +346,10 @@ static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct
                        for (blk = htx_get_first_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) {
                                enum htx_blk_type type = htx_get_blk_type(blk);
 
-                               if (type == HTX_BLK_TLR || type == HTX_BLK_EOT)
-                                       break;
                                if (type == HTX_BLK_DATA)
                                        len += htx_get_blksz(blk);
+                               if (type == HTX_BLK_TLR || type == HTX_BLK_EOT || (blk->flags & HTX_BLK_FL_EOM))
+                                       break;
                        }
                        end = ultoa_o(len, trash.area, trash.size);
                        if (http_add_header(htx, ist("content-length"), ist2(trash.area, end-trash.area), 0)) {