]> 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, 18 Sep 2026 15:05:18 +0000 (17:05 +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 d77ae10eaeeebf939bedc0ecfec09f693e28dd06..79c1f8e570e349cf0ca8dfb081e38c4da1c15758 100644 (file)
@@ -351,10 +351,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)) {