@@ -22,7 +22,7 @@ use Test::Nginx;
22
22
select STDERR ; $| = 1;
23
23
select STDOUT ; $| = 1;
24
24
25
- my $t = Test::Nginx-> new()-> has(qw/ http proxy/ )-> plan(2 );
25
+ my $t = Test::Nginx-> new()-> has(qw/ http proxy upstream_keepalive / )-> plan(4 );
26
26
27
27
$t -> write_file_expand(' nginx.conf' , <<'EOF' );
28
28
@@ -36,6 +36,11 @@ events {
36
36
http {
37
37
%%TEST_GLOBALS_HTTP%%
38
38
39
+ upstream u {
40
+ server 127.0.0.1:8080;
41
+ keepalive 1;
42
+ }
43
+
39
44
server {
40
45
listen 127.0.0.1:8080;
41
46
server_name localhost;
@@ -47,6 +52,15 @@ http {
47
52
add_header X-Msec $msec;
48
53
}
49
54
55
+ location /keepalive {
56
+ proxy_http_version 1.1;
57
+ proxy_set_header Connection "";
58
+ proxy_pass http://u/data;
59
+ proxy_buffer_size 4k;
60
+ proxy_limit_rate 12000;
61
+ add_header X-Msec $msec;
62
+ }
63
+
50
64
location /data {
51
65
}
52
66
}
@@ -69,4 +83,16 @@ my $diff = time() - $t1;
69
83
cmp_ok($diff , ' >=' , 3, ' proxy_limit_rate' );
70
84
like($r , qr / ^(XXXXXXXXXX){4000}\x0d ?\x0a ?$ / m , ' response body' );
71
85
86
+ # in case keepalive connection was saved with the delayed flag,
87
+ # the read timer used to be a delay timer in the next request
88
+
89
+ like(http_get(' /keepalive' ), qr / 200 OK/ , ' keepalive' );
90
+
91
+ TODO: {
92
+ local $TODO = ' not yet' unless $t -> has_version(' 1.13.8' );
93
+
94
+ like(http_get(' /keepalive' ), qr / 200 OK/ , ' keepalive 2' );
95
+
96
+ }
97
+
72
98
# ##############################################################################
0 commit comments