Welcome! Log In Create A New Profile

Advanced

Re: request body filter last_buf

Maxim Dounin
January 28, 2022 06:22PM
Hello!

On Thu, Jan 27, 2022 at 11:02:45AM -0800, Dk Jack wrote:

> Thank you. Last few questions to complete my understanding?
>
> Were the module body filter callbacks being invoked even when
> content_length_n <= 0 prior to 7913:185c86b830ef change?

With content_length_n < 0 (the only valid case is -1) filters were
never called. With content_length_n == 0, filters were called.

Prior to 7913:185c86b830ef, the proper way for filters to detect
that the body was fully read and processed was rb->rest == 0,
which is immediately true when content_length_n is 0, see
ngx_http_request_body_save_filter() for relevant code. In
7913:185c86b830ef and following 7914:9cf043a5d9ca the code was
changed to rely on the last_buf instead, to make it possible to
buffer response parts in intermediate body filters.

> Is the nginx body handling a store-and-forward architecture where it waits
> for the entire body or does it forward pkts as and when it receives
> (especially when dealing with large bodies).

Body handling might be different depending on the settings and/or
particular request handling details. By default, nginx reads the
whole response body into rb->bufs (possible written to a temporary
file) and then forwards the whole body. Additionally, there is
non-buffered request body reading, which is activated with the
r->request_body_no_buffering flag (usually with settings like
"proxy_request_buffering off;"). In this mode nginx forwards
request body data immediately as it is received from the client,
without disk buffering.

> What is the behavior of last_buf if it's not store-and-forward.

The last_buf flag is set on the last buffer, when the whole
request body is read from the client and no additional data will
follow. It doesn't depend on the request body reading mode being
used.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
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 522 January 26, 2022 07:58PM

Re: request body filter last_buf

Maxim Dounin 173 January 26, 2022 08:26PM

Re: request body filter last_buf

dnj0496 249 January 26, 2022 11:40PM

Re: request body filter last_buf

Maxim Dounin 190 January 27, 2022 08:30AM

Re: request body filter last_buf

dnj0496 301 January 27, 2022 02:06PM

Re: request body filter last_buf

Maxim Dounin 225 January 28, 2022 06:22PM



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

Online Users

Guests: 161
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