]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add a function to know if a block is the only one in a message
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Dec 2020 16:40:54 +0000 (17:40 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:37:14 +0000 (16:37 +0100)
The htx_is_unique_blk() function may now be used to know if a block is the
only one in an HTX message, excluding all unused blocks. Note the purpose of
this function is not to know if a block is the last one of an HTTP message.
This means no more data part from the message are expected, except tunneled
data. It only says if a block is alone in an HTX message.

include/haproxy/htx.h

index 31bbcd98299176b808a8aceeaaafcd2a945d7e1d..7cc5ffe605c2dfb683012fd7dadbf76c55f449f5 100644 (file)
@@ -307,6 +307,16 @@ static inline struct htx_blk *htx_get_next_blk(const struct htx *htx,
        return ((pos == -1) ? NULL : htx_get_blk(htx, pos));
 }
 
+/* Returns 1 if <blk> is the block is the only one inside the HTX message <htx>,
+ * excluding all unsued blocks. Otherwise, it returns 0. If 1 is returned, this
+ * means that there is only <blk> and eventually some unused ones in <htx>.
+ */
+static inline int htx_is_unique_blk(const struct htx *htx,
+                                   const struct htx_blk *blk)
+{
+       return (htx_get_blksz(blk) == htx->data);
+}
+
 /* Changes the size of the value. It is the caller responsibility to change the
  * value itself, make sure there is enough space and update allocated
  * value. This function updates the HTX message accordingly.