]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: htx: Handle RAW_DATA blocks like DATA blocks in the HTX API
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 15 Sep 2026 11:59:06 +0000 (13:59 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 15:05:18 +0000 (17:05 +0200)
From the HTX API point of view, a RAW_DATA block is exactly the same as a
DATA block. It carries a payload that may be partially consumed. So the
functions dealing with this property must handle both types the same way:

  * htx_truncate() must be able to truncate such block
  * htx_drain() must be able to partially drain it
  * htx_xfer() must be able to partially transfer it and must of course take
    care to preserve its type

There is no change of behavior because no producer emits RAW_DATA blocks
yet.

src/htx.c

index 81dc04e1ee7bc3b817773267b40963e7ac760332..4ee5272541ec4baabdb337a5ac0b66207834a828 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -518,7 +518,7 @@ void htx_truncate(struct htx *htx, uint32_t offset)
        struct htx_ret htxret = htx_find_offset(htx, offset);
 
        blk = htxret.blk;
-       if (blk && htxret.ret && htx_get_blk_type(blk) == HTX_BLK_DATA) {
+       if (blk && htxret.ret && htx_is_data_type(htx_get_blk_type(blk))) {
                htx_change_blk_value_len(htx, blk, htxret.ret);
                blk = htx_get_next_blk(htx, blk);
        }
@@ -565,7 +565,7 @@ struct htx_ret htx_drain(struct htx *htx, uint32_t count)
                enum htx_blk_type type = htx_get_blk_type(blk);
 
                if (sz > count) {
-                       if (type == HTX_BLK_DATA) {
+                       if (htx_is_data_type(type)) {
                                htx_cut_data_blk(htx, blk, count);
                                htxret.ret += count;
                        }
@@ -868,9 +868,10 @@ size_t htx_xfer(struct htx *dst, struct htx *src, size_t count, unsigned int fla
                sz = htx_get_blksz(blk);
                switch (type) {
                case HTX_BLK_DATA:
+               case HTX_BLK_RAW_DATA:
                        v = htx_get_blk_value(src, blk);
                        v = isttrim(v, max);
-                       v.len = htx_add_data(dst, v);
+                       v.len = htx_add_data_type(dst, v, type);
                        if (!v.len) {
                                dst_full = 1;
                                goto stop;
@@ -964,7 +965,7 @@ size_t htx_xfer(struct htx *dst, struct htx *src, size_t count, unsigned int fla
                         * block is not NULL, it means a partial copy was performed. So
                         * cut the source block accordingly
                         */
-                       if (last_dstblk && blk2 && htx_get_blk_type(blk2) == HTX_BLK_DATA) {
+                       if (last_dstblk && blk2 && htx_is_data_type(htx_get_blk_type(blk2))) {
                                htx_cut_data_blk(src, blk2, last_dstblk_sz);
                        }
                }