Buffers Chain

Paulo Silva pauloasilva at gmail.com
Thu May 22 14:21:56 UTC 2014

Let me introduce the Elephant in the room. My name is Paulo and I'm
from Portugal.
I am starting developing nginx modules and I'm having a great time
with buffers chain :D

I'm using nginx as a reverse proxy and my goal is to log the full
response body (HTML) on the server.

I did start with a filter module with a body_filter and my approach is
as follow:

1. Inspect given ngx_chain_t *in linked list to understand if nginx
has the full response (last_buf)
2. On each body_filter call I'm updating a linked list which glues
given ngx_chain_t *in to the previous ones.
3. As soon as I detect the last_buf, I iterate my internal linked list
(and each linked ngx_chain_t lists), dumping buffers content.

Although I'm reaching the last_buf, I'm missing some bytes.

There is another/better/correct approach to do this?

Thanks in advance,
Paulo A. Silva

More information about the nginx-devel mailing list