request body filter last_buf

Dk Jack dnj0496 at
Thu Jan 27 00:55:52 UTC 2022

in my module I am inspecting the request body and making certain
decisions such as sending a 403 based on the content in the body. I based
my implementation based on the examples in the documentation and other
nginx modules.

Sometimes, when my body_filter handler is invoked, I accumulate the body
into a single buffer for processing in my module. To do this, I have to
first get the length of the body. To get the length, I cycle through the
body buffer chain. I also look for the last_buf to be set for the last
buffer in the chain. The presence of the last_buf tells me that I have the
complete body. However, sometimes I've noticed that the last_buf flag is
not set (I log such requests), in which case I cannot process the body.

Under what conditions would the flag be not set when the body_filter
handler is invoked? Does the body filter handler get invoked multiple times
or only once? Is my assumption that the last_buf flag will always be set
when the body-filter handler is  invoked correct? Any help is appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list