For the record, I found out how to make it work; I must set the buffer I create as being in memory, or the function ngx_buf_size() returns 0. Reading it's deffinition, we can see that it's meant to do so:
#define ngx_buf_size(b) \
(ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \
(b->file_last - b->file_pos))
But the reason behind this decision is not clear to me.
#define ngx_buf_size(b) \
(ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \
(b->file_last - b->file_pos))
But the reason behind this decision is not clear to me.