Send headers in output body filter ?

Alfred Sawaya alfred at huji.fr
Sat Mar 27 02:39:39 UTC 2021


Hello again,


Thank you very much Maxim!

It works perfectly.


Alfred


On 27/03/2021 02:48, Maxim Dounin wrote:
> 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.
>



More information about the nginx-devel mailing list