comparison t/fastcgi-keepalive.t @ 34:e10649a96f39

Keepalive: use fastcgi_keep_conn in tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 03 Sep 2011 12:47:10 +0400
parents 8d8eaaf07663
children
comparison
equal deleted inserted replaced
33:52ca695446d3 34:e10649a96f39
15 ############################################################################### 15 ###############################################################################
16 16
17 select STDERR; $| = 1; 17 select STDERR; $| = 1;
18 select STDOUT; $| = 1; 18 select STDOUT; $| = 1;
19 19
20 my $t = Test::Nginx->new()->plan(6) 20 my $t = Test::Nginx->new()->write_file_expand('nginx.conf', <<'EOF');
21 ->write_file_expand('nginx.conf', <<'EOF');
22 21
23 %%TEST_GLOBALS%% 22 %%TEST_GLOBALS%%
24 23
25 master_process off; 24 master_process off;
26 daemon off; 25 daemon off;
40 listen 127.0.0.1:8080; 39 listen 127.0.0.1:8080;
41 server_name localhost; 40 server_name localhost;
42 41
43 location / { 42 location / {
44 fastcgi_pass backend; 43 fastcgi_pass backend;
44 fastcgi_keep_conn on;
45 } 45 }
46 } 46 }
47 } 47 }
48 48
49 EOF 49 EOF
50 50
51 $t->run_daemon(\&fastcgi_test_daemon); 51 $t->run_daemon(\&fastcgi_test_daemon);
52 $t->run(); 52
53 eval {
54 open OLDERR, ">&", \*STDERR; close STDERR;
55 $t->run();
56 open STDERR, ">&", \*OLDERR;
57 };
58 plan(skip_all => 'no keepalive patches') if $@;
59
60 $t->plan(6);
53 61
54 ############################################################################### 62 ###############################################################################
55
56 {
57 local $TODO = 'needs experimental patches';
58 local $SIG{__WARN__} = sub {};
59 63
60 like(http_get('/'), qr/SEE-THIS/, 'fastcgi request'); 64 like(http_get('/'), qr/SEE-THIS/, 'fastcgi request');
61 like(http_get('/redir'), qr/302/, 'fastcgi redirect'); 65 like(http_get('/redir'), qr/302/, 'fastcgi redirect');
62 like(http_get('/'), qr/^request: 3$/m, 'fastcgi third request'); 66 like(http_get('/'), qr/^request: 3$/m, 'fastcgi third request');
63 67
64 like(http_get('/single'), qr/^connection: 1$/m, 'single connection used'); 68 like(http_get('/single'), qr/^connection: 1$/m, 'single connection used');
65 69
66 }
67
68 # New connection to fastcgi application should be established after HEAD 70 # New connection to fastcgi application should be established after HEAD
69 # requests since nginx doesn't read whole response (as it doesn't need 71 # requests since nginx doesn't read whole response (as it doesn't need
70 # body). 72 # body).
71 73
72 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD'); 74 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD');
73 75
74 {
75 local $TODO = 'needs experimental patches';
76 local $SIG{__WARN__} = sub {};
77
78 like(http_get('/after'), qr/^connection: 2$/m, 'new connection after HEAD'); 76 like(http_get('/after'), qr/^connection: 2$/m, 'new connection after HEAD');
79
80 }
81 77
82 ############################################################################### 78 ###############################################################################
83 79
84 # Simple FastCGI responder implementation. Unlike FCGI and FCGI::Async it's 80 # Simple FastCGI responder implementation. Unlike FCGI and FCGI::Async it's
85 # able to count connections. 81 # able to count connections.