From: Christopher Faulet Date: Thu, 23 May 2019 08:01:34 +0000 (+0200) Subject: MINOR: channel/htx: Add function to forward headers of an HTX message X-Git-Tag: v2.0-dev5~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2f4e83a2826ffe55e32116783709aa2fe6f438d;p=thirdparty%2Fhaproxy.git MINOR: channel/htx: Add function to forward headers of an HTX message The function channel_htx_fwd_headers() should now be used by HTX analyzers to forward all headers of an HTX message, from the start-line to the corresponding EOH. It takes care to update the star-line position. --- diff --git a/include/proto/channel.h b/include/proto/channel.h index b53e177935..077b3ae1f1 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -910,6 +910,26 @@ static inline void channel_slow_realign(struct channel *chn, char *swap) return b_slow_realign(&chn->buf, swap, co_data(chn)); } + +/* Forward all headers of an HTX message, starting from the SL to the EOH. This + * function also updates the start-line position. + */ +static inline void channel_htx_fwd_headers(struct channel *chn, struct htx *htx) +{ + int32_t pos; + size_t data = 0; + + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { + struct htx_blk *blk = htx_get_blk(htx, pos); + data += htx_get_blksz(blk); + if (htx_get_blk_type(blk) == HTX_BLK_EOH) { + htx->sl_pos = htx_get_next(htx, pos); + break; + } + } + c_adv(chn, data); +} + /* * Advance the channel buffer's read pointer by bytes. This is useful * when data have been read directly from the buffer. It is illegal to call