comparison proxy_cache.t @ 912:03e6f4bd35fd

Tests: no client connection close with non-cacheable HEAD requests.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 22 Apr 2016 12:37:14 +0300
parents d1da28e28d1d
children e9064d691790
comparison
equal deleted inserted replaced
911:2668f30181eb 912:03e6f4bd35fd
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http proxy cache gzip shmem/)->plan(13) 24 my $t = Test::Nginx->new()->has(qw/http proxy cache gzip shmem/)->plan(15)
25 ->write_file_expand('nginx.conf', <<'EOF'); 25 ->write_file_expand('nginx.conf', <<'EOF');
26 26
27 %%TEST_GLOBALS%% 27 %%TEST_GLOBALS%%
28 28
29 daemon off; 29 daemon off;
56 proxy_cache_min_uses 1; 56 proxy_cache_min_uses 1;
57 57
58 proxy_cache_use_stale error timeout invalid_header http_500 58 proxy_cache_use_stale error timeout invalid_header http_500
59 http_404; 59 http_404;
60 60
61 proxy_no_cache $arg_e;
62
61 add_header X-Cache-Status $upstream_cache_status; 63 add_header X-Cache-Status $upstream_cache_status;
62 } 64 }
63 } 65 }
64 server { 66 server {
65 listen 127.0.0.1:8081; 67 listen 127.0.0.1:8081;
66 server_name localhost; 68 server_name localhost;
67 69
68 location / { 70 location / {
71 limit_rate 512;
69 } 72 }
70 } 73 }
71 } 74 }
72 75
73 EOF 76 EOF
74 77
75 $t->write_file('t.html', 'SEE-THIS'); 78 $t->write_file('t.html', 'SEE-THIS');
76 $t->write_file('t2.html', 'SEE-THIS'); 79 $t->write_file('t2.html', 'SEE-THIS');
77 $t->write_file('empty.html', ''); 80 $t->write_file('empty.html', '');
81 $t->write_file('big.html', 'x' x 1024);
78 82
79 $t->run(); 83 $t->run();
80 84
81 ############################################################################### 85 ###############################################################################
82 86
108 unlink $t->testdir() . '/empty.html'; 112 unlink $t->testdir() . '/empty.html';
109 like(http_gzip_request('/empty.html'), 113 like(http_gzip_request('/empty.html'),
110 qr/HTTP.*STALE.*14\x0d\x0a.{20}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s, 114 qr/HTTP.*STALE.*14\x0d\x0a.{20}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s,
111 'empty get stale'); 115 'empty get stale');
112 116
117 # no client connection close with response on non-cacheable HEAD requests
118 # see 545b5e4d83b2 in nginx for detailed explanation
119
120 my $s = http(<<EOF, start => 1);
121 HEAD /big.html?e=1 HTTP/1.1
122 Host: localhost
123
124 EOF
125
126 my $r = http_get('/t.html', socket => $s);
127
128 like($r, qr/Connection: keep-alive/, 'non-cacheable head - keepalive');
129
130 TODO: {
131 local $TODO = 'not yet' unless $t->has_version('1.9.13');
132
133 like($r, qr/SEE-THIS/, 'non-cacheable head - second');
134
135 }
136
113 ############################################################################### 137 ###############################################################################
114 138
115 sub http_get_range { 139 sub http_get_range {
116 my ($url, $extra) = @_; 140 my ($url, $extra) = @_;
117 return http(<<EOF); 141 return http(<<EOF);