Welcome! Log In Create A New Profile

Advanced

Re: Send headers in output body filter ?

Maxim Dounin
March 26, 2021 09:50PM
Hello!

On Sat, Mar 27, 2021 at 12:56:16AM +0100, Alfred Sawaya wrote:

> Actually, I will need to modify the http status code depending on the
> output body contents, so it is not just a question of  content-length,
> it is more general than that : I need to have the full backend response
> (headers + body) in order to produce the full client response.
>
>
> It does not seem possible as I understand that the read upstream - write
> downstream loop is hardcoded into nginx, and a module does not have any
> chance to change that, isn't it ?

If you want to change the response status and headers based on the
response body content, the only way is to buffer the response body
and send the response headers after you've done processsing the
response body. Note that since this implies buffering, this is
not going to work for large responses.

Examples of how to implement this can be seen in the image filter
and xslt filter modules.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Send headers in output body filter ?

Alfred Sawaya 246 March 26, 2021 01:06PM

Re: Send headers in output body filter ?

Maxim Dounin 94 March 26, 2021 03:04PM

Re: Send headers in output body filter ?

Alfred Sawaya 115 March 26, 2021 04:06PM

Re: Send headers in output body filter ?

Alfred Sawaya 142 March 26, 2021 07:58PM

Re: Send headers in output body filter ?

Maxim Dounin 144 March 26, 2021 09:50PM

Re: Send headers in output body filter ?

Alfred Sawaya 113 March 26, 2021 10:40PM



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

Online Users

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