Hello! On Wed, Jan 26, 2022 at 04:55:52PM -0800, Dk Jack wrote:
> Hi, > 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. > > http://nginx.org/en/docs/dev/development_guide.html#http_request_body_filters > > 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. The last_buf flag is only guaranteed following 7913:185c86b830ef (http://hg.nginx.org/nginx/rev/185c86b830ef, nginx 1.21.2). Before this, it wasn't present, for example, in requests with empty request body (with "Content-Length: 0"). -- Maxim Dounin http://mdounin.ru/ _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org