comparison http_keepalive.t @ 1509:1603f2bad385

Tests: $sent_http_connection tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 16 Sep 2019 19:13:18 +0300
parents 1a409a166420
children bf69dcabb856
comparison
equal deleted inserted replaced
1508:1a409a166420 1509:1603f2bad385
22 ############################################################################### 22 ###############################################################################
23 23
24 select STDERR; $| = 1; 24 select STDERR; $| = 1;
25 select STDOUT; $| = 1; 25 select STDOUT; $| = 1;
26 26
27 my $t = Test::Nginx->new()->has(qw/http/)->plan(13) 27 my $t = Test::Nginx->new()->has(qw/http/)->plan(14)
28 ->write_file_expand('nginx.conf', <<'EOF'); 28 ->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
32 daemon off; 32 daemon off;
34 events { 34 events {
35 } 35 }
36 36
37 http { 37 http {
38 %%TEST_GLOBALS_HTTP%% 38 %%TEST_GLOBALS_HTTP%%
39
40 log_format test $sent_http_connection;
41 access_log %%TESTDIR%%/test.log test if=$arg_l;
39 42
40 server { 43 server {
41 listen 127.0.0.1:8080; 44 listen 127.0.0.1:8080;
42 server_name localhost; 45 server_name localhost;
43 46
75 ############################################################################### 78 ###############################################################################
76 79
77 # keepalive_requests 80 # keepalive_requests
78 81
79 like(http_keepalive('/'), qr/Connection: keep-alive/, 'keepalive request'); 82 like(http_keepalive('/'), qr/Connection: keep-alive/, 'keepalive request');
80 is(count_keepalive(http_keepalive('/', req => 2)), 1, 'keepalive limit'); 83 is(count_keepalive(http_keepalive('/?l=ok', req => 2)), 1, 'keepalive limit');
81 is(count_keepalive(http_keepalive('/r', req => 3)), 3, 'keepalive merge'); 84 is(count_keepalive(http_keepalive('/r', req => 3)), 3, 'keepalive merge');
82 is(count_keepalive(http_keepalive('/r', req => 5)), 3, 'keepalive merge limit'); 85 is(count_keepalive(http_keepalive('/r', req => 5)), 3, 'keepalive merge limit');
83 86
84 # keepalive_disable 87 # keepalive_disable
85 88
101 my $r = http_keepalive('/', req => 2, sleep => 2.1); 104 my $r = http_keepalive('/', req => 2, sleep => 2.1);
102 is(count_keepalive($r), 1, 'keepalive timeout request'); 105 is(count_keepalive($r), 1, 'keepalive timeout request');
103 like($r, qr/Keep-Alive: timeout=9/, 'keepalive timeout header'); 106 like($r, qr/Keep-Alive: timeout=9/, 'keepalive timeout header');
104 107
105 like(http_keepalive('/zero'), qr/Connection: close/, 'keepalive timeout 0'); 108 like(http_keepalive('/zero'), qr/Connection: close/, 'keepalive timeout 0');
109
110 $t->stop();
111
112 TODO: {
113 local $TODO = 'not yet';
114
115 is($t->read_file('test.log'), "keep-alive\nclose\n", 'sent_http_connection');
116
117 }
106 118
107 ############################################################################### 119 ###############################################################################
108 120
109 sub http_keepalive { 121 sub http_keepalive {
110 my ($url, %opts) = @_; 122 my ($url, %opts) = @_;