Welcome! Log In Create A New Profile

Advanced

Re: request body filter last_buf

January 26, 2022 11:40PM
Thanks Maxim,
Are there any other situations where last_buf would not be set besides the
case of content-length being zero?

On Wed, Jan 26, 2022 at 5:23 PM Maxim Dounin <mdounin@mdounin.ru> wrote:

> 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-leave@nginx.org
>
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

request body filter last_buf

dnj0496 519 January 26, 2022 07:58PM

Re: request body filter last_buf

Maxim Dounin 170 January 26, 2022 08:26PM

Re: request body filter last_buf

dnj0496 245 January 26, 2022 11:40PM

Re: request body filter last_buf

Maxim Dounin 189 January 27, 2022 08:30AM

Re: request body filter last_buf

dnj0496 297 January 27, 2022 02:06PM

Re: request body filter last_buf

Maxim Dounin 224 January 28, 2022 06:22PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 226
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready