~ubuntu-branches/ubuntu/quantal/nginx/quantal-updates

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/t/002-content.t

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2011-04-16 13:47:58 UTC
  • mfrom: (4.2.31 sid)
  • Revision ID: james.westby@ubuntu.com-20110416134758-yqca2qp5crh2hw2f
Tags: 1.0.0-2
* debian/rules:
  + Removed --with-file-aio support. Fixed FTBFS on kFreeBSD-* arch
    (Closes: #621882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
use Test::Nginx::Socket;
4
4
 
5
5
#worker_connections(1014);
6
 
#master_process_enabled(1);
7
 
log_level('warn');
 
6
#master_on();
 
7
#workers(2);
 
8
#log_level('warn');
8
9
 
9
10
repeat_each(2);
10
11
#repeat_each(1);
11
12
 
12
 
plan tests => repeat_each() * (blocks() * 2 + 1);
 
13
plan tests => repeat_each() * (blocks() * 2 + 2);
13
14
 
14
15
#no_diff();
15
16
#no_long_string();
405
406
 
406
407
 
407
408
 
408
 
=== TEST 24: capture location headers
 
409
=== TEST 24: capture location multi-value headers
 
410
--- config
 
411
    location /other {
 
412
        #echo "hello, world";
 
413
        content_by_lua '
 
414
            ngx.header["Set-Cookie"] = {"a", "hello, world", "foo"}
 
415
            ngx.eof()
 
416
        ';
 
417
    }
 
418
 
 
419
    location /lua {
 
420
        content_by_lua '
 
421
            res = ngx.location.capture("/other");
 
422
            ngx.say("type: ", type(res.header["Set-Cookie"]));
 
423
            ngx.say("len: ", #res.header["Set-Cookie"]);
 
424
            ngx.say("value: ", table.concat(res.header["Set-Cookie"], "|"))
 
425
        ';
 
426
    }
 
427
--- request
 
428
GET /lua
 
429
--- response_body
 
430
type: table
 
431
len: 3
 
432
value: a|hello, world|foo
 
433
 
 
434
 
 
435
 
 
436
=== TEST 25: capture location headers
409
437
--- config
410
438
    location /other {
411
439
        default_type 'foo/bar';
429
457
 
430
458
 
431
459
 
432
 
=== TEST 25: capture location headers
 
460
=== TEST 26: capture location headers
433
461
--- config
434
462
    location /other {
435
463
        default_type 'foo/bar';
452
480
type: foo/bar
453
481
Bar: nil
454
482
 
 
483
 
 
484
 
 
485
=== TEST 27: HTTP 1.0 response
 
486
--- config
 
487
    location /lua {
 
488
        content_by_lua '
 
489
            data = "hello, world"
 
490
            -- ngx.header["Content-Length"] = #data
 
491
            -- ngx.header.content_length = #data
 
492
            ngx.print(data)
 
493
        ';
 
494
    }
 
495
    location /main {
 
496
        proxy_pass http://127.0.0.1:$server_port/lua;
 
497
    }
 
498
--- request
 
499
GET /main
 
500
--- response_headers
 
501
Content-Length: 12
 
502
--- response_body chop
 
503
hello, world
 
504
 
 
505
 
 
506
 
 
507
=== TEST 28: multiple eof
 
508
--- config
 
509
    location /lua {
 
510
        content_by_lua '
 
511
            ngx.say("Hi")
 
512
            ngx.eof()
 
513
            ngx.eof()
 
514
        ';
 
515
    }
 
516
--- request
 
517
GET /lua
 
518
--- response_body
 
519
Hi
 
520
 
 
521
 
 
522
 
 
523
=== TEST 29: nginx vars in script path
 
524
--- config
 
525
    location ~ ^/lua/(.+)$ {
 
526
        content_by_lua_file html/$1.lua;
 
527
    }
 
528
--- user_files
 
529
>>> calc.lua
 
530
local a,b = ngx.var.arg_a, ngx.var.arg_b
 
531
ngx.say(a+b)
 
532
--- request
 
533
GET /lua/calc?a=19&b=81
 
534
--- response_body
 
535
100
 
536
 
 
537
 
 
538
 
 
539
=== TEST 30: nginx vars in script path
 
540
--- config
 
541
    location ~ ^/lua/(.+)$ {
 
542
        content_by_lua_file html/$1.lua;
 
543
    }
 
544
    location /main {
 
545
        echo_location /lua/sum a=3&b=2;
 
546
        echo_location /lua/diff a=3&b=2;
 
547
    }
 
548
--- user_files
 
549
>>> sum.lua
 
550
local a,b = ngx.var.arg_a, ngx.var.arg_b
 
551
ngx.say(a+b)
 
552
>>> diff.lua
 
553
local a,b = ngx.var.arg_a, ngx.var.arg_b
 
554
ngx.say(a-b)
 
555
--- request
 
556
GET /main
 
557
--- response_body
 
558
5
 
559
1
 
560