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.
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
{
struct channel *chn;
struct htx *htx;
+ struct htx_blk *blk;
if (!smp->strm)
return 0;
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;