]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: http-htx: Really test the EOM flag presence in internal.htx.has_eom
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 15 Sep 2026 12:00:58 +0000 (14:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 15:05:19 +0000 (17:05 +0200)
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.

doc/configuration.txt
src/http_htx.c

index 517d7104febe837dcbfe95560757926aca1a92c5..638eb81f9aed6f1473f61ea0e7e179cc5aecf3a8 100644 (file)
@@ -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
index 8c91ff5eb0eff674758d0aeee1abf3e9a436a7ac..c22545a11618ea26cb00aced025d083ca6f06174 100644 (file)
@@ -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;