MEDIUM: filters/htx: Filter body relatively to the first block
The filters filtering HTX body, in the callback http_payload, must now loop on
an HTX message starting from the first block position. The offset passed as
parameter is relative to this position and not the head one. It is mandatory
because once filtered, data are now forwarded using the function
channel_htx_fwd_payload(). So the first block position is always updated.
diff --git a/src/cache.c b/src/cache.c
index 4371910..83aacd1 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -336,7 +336,6 @@
struct cache_st *st = filter->ctx;
struct htx *htx = htxbuf(&msg->chn->buf);
struct htx_blk *blk;
- struct htx_ret htx_ret;
struct cache_entry *object;
int ret, to_forward = 0;
@@ -349,16 +348,17 @@
}
object = (struct cache_entry *)st->first_block->data;
- htx_ret = htx_find_blk(htx, offset);
- blk = htx_ret.blk;
- offset = htx_ret.ret;
-
- while (blk && len) {
+ for (blk = htx_get_first_blk(htx); blk && len; blk = htx_get_next_blk(htx, blk)) {
struct shared_block *fb;
enum htx_blk_type type = htx_get_blk_type(blk);
uint32_t sz = htx_get_blksz(blk);
struct ist v;
+ if (offset >= sz) {
+ offset -= sz;
+ continue;
+ }
+
switch (type) {
case HTX_BLK_UNUSED:
break;
@@ -400,7 +400,6 @@
}
offset = 0;
- blk = htx_get_next_blk(htx, blk);
}
return to_forward;