]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel/htx: Add function to forward headers of an HTX message
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 May 2019 08:01:34 +0000 (10:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 May 2019 05:42:33 +0000 (07:42 +0200)
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.

include/proto/channel.h

index b53e177935d77f8e128ea6712fdbe8cb4134f6f3..077b3ae1f191191ade48c8aa353ac28234717aa8 100644 (file)
@@ -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 <len> bytes. This is useful
  * when data have been read directly from the buffer. It is illegal to call