Skip to content

Commit 594f55b

Browse files
committed
added a test case to exercise a bug in ngx_gunzip module with which ngx.flush(true) could hang forever. thanks Maxim Dounin for the catch. to make this test pass, we need the gzip_flush_bug patch applied to the nginx core.
1 parent 4615fd5 commit 594f55b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

t/056-flush.t

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use t::TestNginxLua;
1414

1515
repeat_each(2);
1616

17-
plan tests => repeat_each() * 54;
17+
plan tests => repeat_each() * 55;
1818

1919
#no_diff();
2020
no_long_string();
@@ -456,3 +456,34 @@ Content-Encoding: gzip
456456
--- no_error_log
457457
[error]
458458
459+
460+
461+
=== TEST 16: flush wait - gunzip
462+
--- config
463+
location /test {
464+
gunzip on;
465+
content_by_lua '
466+
local f, err = io.open(ngx.var.document_root .. "/gzip.bin", "r")
467+
if not f then
468+
ngx.say("failed to open file: ", err)
469+
return
470+
end
471+
local data = f:read(100)
472+
ngx.header.content_encoding = "gzip"
473+
ngx.print(data)
474+
local ok, err = ngx.flush(true)
475+
if not ok then
476+
ngx.log(ngx.ERR, "flush failed: ", err)
477+
return
478+
end
479+
';
480+
}
481+
--- user_files eval
482+
">>> gzip.bin
483+
\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\x03\xb5\x19\xdb\x6e\x1b\xc7\xf5\x9d\x5f\x31\x5d\xa3\xa0\x84\x68\x2f\xbc\xc8\xb2\x28\x92\x85\x2d\x19\x8e\x01\x4b\x11\x6a\xa5\x69\x60\x18\xc2\x70\x77\xb8\x1c\x6b\xb9\xb3\x9e\x99\x25\xc5\x24\x06\x12\xe4\xa1\xcf\x45\x81\x16\x05\x8a\x3e\x14\x28\x5a\x04\x6d\x9f\xd3\xa2\x7d\xca\x0f\xd8\x4f\xfe\x81\xc0\xed\x67\xf4\x9c\xd9\x5d\x72\x79\x91\x25\x32\x91\x04\x51\x7b\xe6\x5c"
484+
--- request
485+
GET /test
486+
--- ignore_response
487+
--- no_error_log
488+
[error]
489+

util/build2.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ time ngx-build $force $version \
4444
--add-module=$root/../rds-json-nginx-module \
4545
--add-module=$root/../coolkit-nginx-module \
4646
--add-module=$root/../redis2-nginx-module \
47+
--with-http_gunzip_module \
4748
--with-select_module \
4849
--with-poll_module \
4950
--with-rtsig_module \

0 commit comments

Comments
 (0)