From: Christopher Faulet Date: Wed, 8 Jul 2026 08:23:11 +0000 (+0200) Subject: MINOR: htx: Remove htx_xfer_blks function X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=2da1b65f9a881febab7aff8936491a87f1a423b9;p=haproxy.git MINOR: htx: Remove htx_xfer_blks function This function was deprecated during the 3.4 dev cycle and is no longer used. So let's remove it. --- diff --git a/doc/internals/api/htx-api.txt b/doc/internals/api/htx-api.txt index 32a3a8a72..02728c7b8 100644 --- a/doc/internals/api/htx-api.txt +++ b/doc/internals/api/htx-api.txt @@ -551,17 +551,6 @@ message. These functions are used by HTX analyzers or by multiplexers. part can be xferred - HTX_XFER_HDRS_ONLY: Only the headers part is xferred - - htx_xfer_blks() [DEPRECATED] transfers HTX blocks from an HTX message to - another, stopping after the first block of a specified type is transferred - or when a specific amount of bytes, including meta-data, was moved. If the - tail block is a DATA block, it may be partially moved. All other block are - transferred at once or kept. This function returns a mixed value, with the - last block moved, or NULL if nothing was moved, and the amount of data - transferred. When HEADERS or TRAILERS blocks must be transferred, this - function transfers all of them. Otherwise, if it is not possible, it - triggers an error. It is the caller responsibility to transfer all headers - or trailers at once. - - htx_append_msg() append an HTX message to another one. All the message is copied or nothing. So, if an error occurred, a rollback is performed. This function returns 1 on success and 0 on error. diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index f6181908c..ce4511225 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -42,9 +42,6 @@ struct htx_ret htx_drain(struct htx *htx, uint32_t max); struct htx_blk *htx_replace_blk_value(struct htx *htx, struct htx_blk *blk, const struct ist old, const struct ist new); -struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count, - enum htx_blk_type mark); - struct htx_sl *htx_replace_stline(struct htx *htx, struct htx_blk *blk, const struct ist p1, const struct ist p2, const struct ist p3); diff --git a/src/htx.c b/src/htx.c index 2a369f30f..3a05dc42f 100644 --- a/src/htx.c +++ b/src/htx.c @@ -900,124 +900,6 @@ size_t htx_xfer(struct htx *dst, struct htx *src, size_t count, unsigned int fla return ret; } -/* Transfer HTX blocks from to , stopping once the first block of the - * type is transferred (typically EOH or EOT) or when bytes were - * moved (including payload and meta-data). It returns the number of bytes moved - * and the last HTX block inserted in . - * - * DEPRECATED - */ -struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count, - enum htx_blk_type mark) -{ - struct htx_blk *blk, *dstblk; - struct htx_blk *srcref, *dstref; - struct ist v; - enum htx_blk_type type; - uint32_t max, sz, ret; - - ret = htx_used_space(dst); - srcref = dstref = dstblk = NULL; - - /* blocks are not removed yet from HTX message to be able to - * rollback the transfer if all the headers/trailers are not copied. - */ - for (blk = htx_get_head_blk(src); blk && count; blk = htx_get_next_blk(src, blk)) { - type = htx_get_blk_type(blk); - sz = htx_get_blksz(blk); - - /* Ignore unused block */ - if (type == HTX_BLK_UNUSED) - continue; - - max = htx_get_max_blksz(dst, count); - if (!max) - break; - - switch (type) { - case HTX_BLK_DATA: - v = htx_get_blk_value(src, blk); - v = isttrim(v, max); - v.len = htx_add_data(dst, v); - if (!v.len) - goto stop; - dstblk = htx_get_tail_blk(dst); - count -= sizeof(*dstblk) + v.len; - if (v.len != sz) { - /* Partial xfer: don't remove from but - * resize its content */ - htx_cut_data_blk(src, blk, v.len); - goto stop; - } - break; - default: - /* Only DATA blocks can be partially xferred */ - if (sz > max) - goto stop; - dstblk = htx_add_blk(dst, type, sz); - if (!dstblk) - goto stop; - dstblk->info = blk->info; - htx_memcpy(htx_get_blk_ptr(dst, dstblk), htx_get_blk_ptr(src, blk), sz); - count -= sizeof(*dstblk) + sz; - break; - } - - /* Save to and to when we start - * to xfer headers or trailers. When EOH/EOT block is reached, - * both are reset. It is mandatory to be able to rollback a - * partial transfer. - */ - if (!srcref && !dstref && - (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL || type == HTX_BLK_TLR)) { - srcref = blk; - dstref = dstblk; - } - else if (type == HTX_BLK_EOH || type == HTX_BLK_EOT) - srcref = dstref = NULL; - - /* allows a copy of the block which matched, then stop */ - if (type == mark) { - blk = htx_get_next_blk(src, blk); - break; - } - } - stop: - if (unlikely(dstref)) { - /* Headers or trailers part was partially xferred, so rollback - * the copy by removing all block between and , - * both included. may be NULL. - */ - while (dstref && dstref != dstblk) - dstref = htx_remove_blk(dst, dstref); - if (dstblk) - htx_remove_blk(dst, dstblk); - - /* HTX message is empty, it means the headers or trailers - * part is too big to be copied at once. - */ - if (htx_is_empty(dst)) - src->flags |= HTX_FL_PARSING_ERROR; - } - - /* Now, remove xferred blocks from htx message */ - if (!blk && !srcref) { - /* End of src reached, all blocks were consumed, drain all data */ - htx_drain(src, src->data); - } - else { - /* Remove all block from the head to , or if defined, excluded */ - srcref = (srcref ? srcref : blk); - for (blk = htx_get_head_blk(src); blk && blk != srcref; blk = htx_remove_blk(src, blk)); - } - - if (htx_is_empty(src)) - dst->flags |= (src->flags & (HTX_FL_EOM|HTX_FL_PARSING_ERROR|HTX_FL_PROCESSING_ERROR)); - - ret = htx_used_space(dst) - ret; - return (struct htx_ret){.ret = ret, .blk = dstblk}; -} - /* Replaces an header by a new one. The new header can be smaller or larger than * the old one. It returns the new block on success, otherwise it returns NULL. * The header name is always lower cased.