comparison http_keepalive.t @ 1668:0c1bd4c23c95

Tests: $connection_requests and $connection_time tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 08 Apr 2021 14:51:04 +0300
parents bdebd63dbab3
children 489484af31eb
comparison
equal deleted inserted replaced
1667:bdebd63dbab3 1668:0c1bd4c23c95
46 listen 127.0.0.1:8080; 46 listen 127.0.0.1:8080;
47 server_name localhost; 47 server_name localhost;
48 48
49 keepalive_requests 2; 49 keepalive_requests 2;
50 keepalive_timeout 1 9; 50 keepalive_timeout 1 9;
51
52 add_header X-Conn $connection_requests:$connection_time;
51 53
52 location / { } 54 location / { }
53 location /r { 55 location /r {
54 keepalive_requests 4; 56 keepalive_requests 4;
55 keepalive_timeout 30s; 57 keepalive_timeout 30s;
81 $t->write_file('r', ''); 83 $t->write_file('r', '');
82 $t->write_file('time', ''); 84 $t->write_file('time', '');
83 $t->write_file('safari', ''); 85 $t->write_file('safari', '');
84 $t->write_file('none', ''); 86 $t->write_file('none', '');
85 $t->write_file('zero', ''); 87 $t->write_file('zero', '');
86 $t->try_run('no keepalive_time')->plan(20); 88 $t->try_run('no keepalive_time')->plan(21);
87 89
88 ############################################################################### 90 ###############################################################################
89 91
90 # keepalive_requests 92 # keepalive_requests
91 93
125 127
126 $r = http_keepalive('/time', req => 3, sleep => 1.1); 128 $r = http_keepalive('/time', req => 3, sleep => 1.1);
127 is(() = $r =~ /(200 OK)/g, 2, 'keepalive time limit requests'); 129 is(() = $r =~ /(200 OK)/g, 2, 'keepalive time limit requests');
128 like($r, qr/Connection: close/, 'keepalive time limit connection'); 130 like($r, qr/Connection: close/, 'keepalive time limit connection');
129 131
132 like($r, qr/X-Conn: 1:0.*X-Conn: 2:[^0]/s, 'keepalive time limit variables');
133
130 # cancel keepalive on EOF while discarding body 134 # cancel keepalive on EOF while discarding body
131 135
132 my $s = http(<<EOF, start => 1); 136 my $s = http(<<EOF, start => 1);
133 POST /r HTTP/1.1 137 POST /r HTTP/1.1
134 Host: localhost 138 Host: localhost