From: Christopher Faulet Date: Tue, 15 Sep 2026 12:00:58 +0000 (+0200) Subject: MINOR: http-htx: Really test the EOM flag presence in internal.htx.has_eom X-Git-Tag: v3.5-dev8~142 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=753d0e4d10327927384a9d3d5ff2b44077a11c86;p=haproxy.git MINOR: http-htx: Really test the EOM flag presence in internal.htx.has_eom The "internal.htx.has_eom" sample fetch is documented to return true if the HTX message contains the end-of-message flag. It relied on htx_msg_ended() to do so. But this function now also reports the end of the message when the block carrying the flag was already consumed, which is the case when the tail block is a RAW_DATA block. Because this sample fetch is a debugging helper, it must really answer the question it is documented for. So the HTX message is now scanned, looking for a block carrying the flag. Note the scan is performed from the head on purpose. This way, no assumption is made about the position of the block carrying the flag and an unexpected one would be reported. The documentation was updated to mention the flag may already have been consumed, in which case false is returned while the end of the message was already reached. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 517d7104f..638eb81f9 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -28756,9 +28756,11 @@ internal.htx.free_data : integer a channel. The channel is chosen depending on the sample direction. internal.htx.has_eom : boolean - Returns true if the HTX message associated to a channel contains the - end-of-message flag (EOM). Otherwise, it returns false. The channel is chosen - depending on the sample direction. + Returns true if the HTX message associated to a channel contains a block + carrying the end-of-message flag (EOM). Otherwise, it returns false. Note the + block carrying this flag may already have been consumed, in which case false + is returned while the end of the message was already reached. The channel is + chosen depending on the sample direction. internal.htx.nbblks : integer Returns the number of blocks present in the HTX message associated to a diff --git a/src/http_htx.c b/src/http_htx.c index 8c91ff5eb..c22545a11 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -2822,6 +2822,7 @@ smp_fetch_htx_has_eom(const struct arg *arg_p, struct sample *smp, const char *k { struct channel *chn; struct htx *htx; + struct htx_blk *blk; if (!smp->strm) return 0; @@ -2831,7 +2832,20 @@ smp_fetch_htx_has_eom(const struct arg *arg_p, struct sample *smp, const char *k if (!htx) return 0; - smp->data.u.sint = htx_msg_ended(htx); + /* Look for a block carrying the EOM flag. htx_msg_ended() cannot be + * used here because it also reports the end of the message when the + * block carrying the flag was already consumed. Here we really want to + * know if the HTX message contains such block. Note it is not + * necessarily the tail block because tunneled data may be stored after + * the end of the message. + */ + smp->data.u.sint = 0; + for (blk = htx_get_head_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) { + if (blk->flags & HTX_BLK_FL_EOM) { + smp->data.u.sint = 1; + break; + } + } smp->data.type = SMP_T_BOOL; smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE; return 1;