<div dir="ltr">Thanks Maxim,<div>Are there any other situations where last_buf would not be set besides the case of content-length being zero?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 26, 2022 at 5:23 PM Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Wed, Jan 26, 2022 at 04:55:52PM -0800, Dk Jack wrote:<br>
<br>
> Hi,<br>
> in my module I am inspecting the request body and making certain<br>
> decisions such as sending a 403 based on the content in the body. I based<br>
> my implementation based on the examples in the documentation and other<br>
> nginx modules.<br>
> <br>
> <a href="http://nginx.org/en/docs/dev/development_guide.html#http_request_body_filters" rel="noreferrer" target="_blank">http://nginx.org/en/docs/dev/development_guide.html#http_request_body_filters</a><br>
> <br>
> Sometimes, when my body_filter handler is invoked, I accumulate the body<br>
> into a single buffer for processing in my module. To do this, I have to<br>
> first get the length of the body. To get the length, I cycle through the<br>
> body buffer chain. I also look for the last_buf to be set for the last<br>
> buffer in the chain. The presence of the last_buf tells me that I have the<br>
> complete body. However, sometimes I've noticed that the last_buf flag is<br>
> not set (I log such requests), in which case I cannot process the body.<br>
> <br>
> Under what conditions would the flag be not set when the body_filter<br>
> handler is invoked? Does the body filter handler get invoked multiple times<br>
> or only once? Is my assumption that the last_buf flag will always be set<br>
> when the body-filter handler is invoked correct? Any help is appreciated.<br>
<br>
The last_buf flag is only guaranteed following 7913:185c86b830ef <br>
(<a href="http://hg.nginx.org/nginx/rev/185c86b830ef" rel="noreferrer" target="_blank">http://hg.nginx.org/nginx/rev/185c86b830ef</a>, nginx 1.21.2). <br>
Before this, it wasn't present, for example, in requests <br>
with empty request body (with "Content-Length: 0").<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx-devel mailing list -- <a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
To unsubscribe send an email to <a href="mailto:nginx-devel-leave@nginx.org" target="_blank">nginx-devel-leave@nginx.org</a><br>
</blockquote></div>