~spuul/nginx/trunk

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/t/056-flush.t

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-02-15 03:05:42 UTC
  • mfrom: (4.3.10 sid)
  • Revision ID: package-import@ubuntu.com-20140215030542-71ubtowl24vf7nfn
Tags: 1.4.5-1ubuntu1
* Resynchronise with Debian (LP: #1280511).  Remaining changes:
  - debian/patches/ubuntu-branding.patch:
    + Add Ubuntu branding to server_tokens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
}
6
6
 
7
7
use lib 'lib';
8
 
use Test::Nginx::Socket;
 
8
use Test::Nginx::Socket::Lua;
9
9
 
10
10
#worker_connections(1014);
11
11
#master_on();
14
14
 
15
15
repeat_each(2);
16
16
 
17
 
plan tests => repeat_each() * 44;
 
17
plan tests => repeat_each() * 55;
18
18
 
19
19
#no_diff();
20
20
no_long_string();
27
27
    location /test {
28
28
        content_by_lua '
29
29
            ngx.say("hello, world")
30
 
            ngx.flush(true)
 
30
            local ok, err = ngx.flush(true)
 
31
            if not ok then
 
32
                ngx.log(ngx.ERR, "flush failed: ", err)
 
33
                return
 
34
            end
31
35
            ngx.say("hiya")
32
36
        ';
33
37
    }
36
40
--- response_body
37
41
hello, world
38
42
hiya
 
43
--- no_error_log
 
44
[error]
39
45
--- error_log
40
46
lua reuse free buf memory 13 >= 5
41
47
 
47
53
    location /test {
48
54
        content_by_lua '
49
55
            ngx.say("hello, world")
50
 
            ngx.flush(false)
 
56
            local ok, err = ngx.flush(false)
 
57
            if not ok then
 
58
                ngx.log(ngx.ERR, "flush failed: ", err)
 
59
                return
 
60
            end
51
61
            ngx.say("hiya")
52
62
        ';
53
63
    }
126
136
    location /test {
127
137
        content_by_lua '
128
138
            ngx.say("hello, world")
129
 
            ngx.flush(false)
 
139
            local ok, err = ngx.flush(false)
 
140
            if not ok then
 
141
                ngx.log(ngx.WARN, "1: failed to flush: ", err)
 
142
            end
130
143
            ngx.say("hiya")
131
 
            ngx.flush(false)
 
144
            local ok, err = ngx.flush(false)
 
145
            if not ok then
 
146
                ngx.log(ngx.WARN, "2: failed to flush: ", err)
 
147
            end
132
148
            ngx.say("blah")
133
149
        ';
134
150
    }
143
159
--- error_log
144
160
lua buffering output bufs for the HTTP 1.0 request
145
161
lua http 1.0 buffering makes ngx.flush() a no-op
 
162
1: failed to flush: buffering
 
163
2: failed to flush: buffering
146
164
--- timeout: 5
147
165
 
148
166
 
390
408
--- error_log
391
409
lua reuse free buf memory 13 >= 5
392
410
 
 
411
 
 
412
 
 
413
=== TEST 14: flush before sending out the header
 
414
--- config
 
415
    location /test {
 
416
        content_by_lua '
 
417
            ngx.flush()
 
418
            ngx.status = 404
 
419
            ngx.say("not found")
 
420
        ';
 
421
    }
 
422
--- request
 
423
GET /test
 
424
--- response_body
 
425
not found
 
426
--- error_code: 404
 
427
--- no_error_log
 
428
[error]
 
429
 
 
430
 
 
431
 
 
432
=== TEST 15: flush wait - gzip
 
433
--- config
 
434
    gzip             on;
 
435
    gzip_min_length  1;
 
436
    gzip_types       text/plain;
 
437
 
 
438
    location /test {
 
439
        content_by_lua '
 
440
            ngx.say("hello, world")
 
441
            local ok, err = ngx.flush(true)
 
442
            if not ok then
 
443
                ngx.log(ngx.ERR, "flush failed: ", err)
 
444
                return
 
445
            end
 
446
            ngx.say("hiya")
 
447
        ';
 
448
    }
 
449
--- request
 
450
GET /test
 
451
--- more_headers
 
452
Accept-Encoding: gzip
 
453
--- response_body_like: .{15}
 
454
--- response_headers
 
455
Content-Encoding: gzip
 
456
--- no_error_log
 
457
[error]
 
458
 
 
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
            data = f:read("*a")
 
480
            ngx.print(data)
 
481
        ';
 
482
    }
 
483
--- user_files eval
 
484
">>> gzip.bin
 
485
\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x62\x64\x62\x62\x61\x62\x64\x63\x61\xe4\xe0\xe2\xe6\xe4\x61\xe4\xe4\xe7\x63\x12\xe4\xe1\xe0\x60\x14\x12\xe3\x91\xe4\xe4\xe4\x13\x60\xe3\x95\x12\x90\x15\xe0\x11\x50\x92\xd1\x16\x17\xe2\xd3\x17\x14\x11\x95\x95\x57\x96\x63\x37\xd2\x36\xd6\x51\x34\xb1\xe6\x62\x17\x95\xb0\x77\x60\xe3\x96\x33\x95\xb6\x91\x75\x97\x30\xe4\x66\x0c\xd0\xe3\xe0\xb5\xd3\x33\xf6\x90\x16\xb2\x90\x77\x56\x31\xe7\x55\x32\x11\x74\xe0\x02\x00\x00\x00\xff\xff\xcb\xc8\xac\x4c\xe4\x02\x00\x19\x15\xa9\x77\x6a\x00\x00\x00"
 
486
--- request
 
487
GET /test
 
488
--- ignore_response
 
489
--- no_error_log
 
490
[error]
 
491