htx_add_data() is able to partially consume data. However there is a bug
when the HTX buffer is empty. The data length is not properly
adjusted. Thus, if it exceeds the HTX buffer size, no block is added. To fix
the issue, the length is now adjusted first.
This patch must be backported as far as 2.0.
uint32_t sz, room;
int32_t len = data.len;
- if (htx->head == -1)
- goto add_new_block;
-
/* Not enough space to store data */
if (len > htx_free_data_space(htx))
len = htx_free_data_space(htx);
if (!len)
return 0;
+ if (htx->head == -1)
+ goto add_new_block;
+
/* get the tail and head block */
tailblk = htx_get_tail_blk(htx);
if (tailblk == NULL)