In decomp_stream_blk(), only the EOT block was held while decompressed
data were still pending. TLR blocks, and the NOOP block carrying the EOM
since commit
221c40bbf ("MINOR: htx: Add a noop block to carry the EOM
flag on an empty message"), were forwarded immediately. When the
decompressed data did not all fit in the buffer, the trailers and the
end of the message were thus sent before the remaining data: a chunked
gzip response of 30kB with a trailer was delivered as a complete message
of 15.8kB. In the request direction, it led to a 500 with "IH--".
Now these blocks are handled like the EOT block. In addition, when the
decompression state is flushed on such a block and the decompression is
finished with nothing left to emit, the block is now counted as
forwarded, otherwise the following ones would be counted while this one
is not. The filter was introduced in 3.5-dev6 by commit
f0710d808
("MEDIUM: flt-decomp: implement decomp-req and decomp-res filters"), so
no backport is needed.
}
break;
+ case HTX_BLK_NOOP:
+ if (!(blk->flags & HTX_BLK_FL_EOM))
+ goto consume;
+ __fallthrough;
+ case HTX_BLK_TLR:
case HTX_BLK_EOT:
if (st->decomp_ctx->drain_len) {
/* there is still pending data that we need to drain */
if (ret == -1)
goto error;
- break; /* if decomp_ctx->drain_len is set it will be taken
- * care of
- */
-
+ /* If some data are pending or if the decompression
+ * is not finished, this block and the following
+ * ones must not be forwarded yet. Pending data will
+ * be drained later, before this block. Otherwise,
+ * the decompression is finished with no data left,
+ * so this block must be counted as forwarded. It
+ * must not be skipped while the following ones are
+ * counted.
+ */
+ if (st->decomp_ctx->drain_len ||
+ !(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE))
+ break;
}
/* don't forget some out of payload data such as EOT count as forwarded
break;
default:
+ consume:
/* nothing to do with that, just forward */
total += htx_get_blksz(blk);
break;