﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
2055	"Using addition_filter and changing the added file: still returning ""304 Not Modified"""	sijanec@…		"Hello!

I have just stumbled upon a nginx bug. When using add_before_body and/or add_after_body commands from ngx_http_addition_filter_module, the server will respond with ""304 Not Modified"" even if the added file has changed.

After investigation I figured out that this error could be applied to everything that uses ngx_http_subrequest to gather data. The request structure will remain with the same last_modified_time even if the subrequest contains data that was modified after this time. The solution to this problem would be to overwrite the request structure headers_out.last_modified_time with the last_modified_time in the structure, generated by ngx_http_subrequest, if it's in the future, but that would not be enough.

The problem is that ngx_http_subrequest does not populate the request struct, specified as it's fourth argument, with headers_out.last_modified_time, it stays at -1, but that wouldn't help very much in this particular case.

Even setting the headers_out.last_modified_time to -1 in addition_filter_module would not work and would not fix the issue, because the filter modules do not execute before not_modified module (nginx/auto/modules:142).

Well, at last resort, the not_modified module could load configuration of addition_filter module and, if addition is to be done, return to the next module. But that would not work either; the not_modified module source is included before the addition_filter so it's module struct and relying configurations are not available at the time of compilation.

Proof of bug: Run nginx with attached nginx.conf and create files /tmp/add.html and /tmp/index.html with some content. Load http://localhost:8080/ in a modern Firefox browser. Then change the file /tmp/add.html and nginx will proceed to report ""304 Not Modified"" and your browser's copy will after page refresh remain with the old /tmp/add.html file added at the beginning of the response.

Regards!"	defect	closed	minor		nginx-module	1.19.x	wontfix			Linux kondenzator 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux	"a@kondenzator:~[1]$ /tmp/nginx/objs/nginx  -V
nginx version: nginx/1.19.3
built by gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
configure arguments: --with-http_addition_module
a@kondenzator:~[0]$ 
"
