comparison proxy_cache_use_stale.t @ 1256:fc43a3555095

Tests: added uri escaping tests to proxy_cache_use_stale.t.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 06 Dec 2017 13:52:52 +0300
parents 766bcbb632ee
children 97c8280de681
comparison
equal deleted inserted replaced
1255:b113eeca94ad 1256:fc43a3555095
46 server_name localhost; 46 server_name localhost;
47 47
48 location /ssi.html { 48 location /ssi.html {
49 ssi on; 49 ssi on;
50 sendfile_max_chunk 4k; 50 sendfile_max_chunk 4k;
51 }
52
53 location /escape {
54 proxy_pass http://127.0.0.1:8081;
55 proxy_cache NAME;
56 proxy_cache_background_update on;
57 add_header X-Cache-Status $upstream_cache_status;
51 } 58 }
52 59
53 location / { 60 location / {
54 proxy_pass http://127.0.0.1:8081; 61 proxy_pass http://127.0.0.1:8081;
55 62
132 $t->write_file('t3.html', 'SEE-THIS'); 139 $t->write_file('t3.html', 'SEE-THIS');
133 $t->write_file('t6.html', 'SEE-THIS'); 140 $t->write_file('t6.html', 'SEE-THIS');
134 $t->write_file('t7.html', 'SEE-THIS' x 1024); 141 $t->write_file('t7.html', 'SEE-THIS' x 1024);
135 $t->write_file('t9.html', 'SEE-THIS' x 1024); 142 $t->write_file('t9.html', 'SEE-THIS' x 1024);
136 $t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html" --> xxx'); 143 $t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html" --> xxx');
137 144 $t->write_file('escape.html', 'SEE-THIS');
138 $t->run()->plan(29); 145 $t->write_file('escape html', 'SEE-THIS');
146
147 $t->run()->plan(33);
139 148
140 ############################################################################### 149 ###############################################################################
141 150
142 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error'); 151 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error');
143 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached'); 152 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached');
154 get('/t7.html', 'max-age=1, stale-while-revalidate=10'); 163 get('/t7.html', 'max-age=1, stale-while-revalidate=10');
155 http_get('/ssi.html'); 164 http_get('/ssi.html');
156 get('/updating/t.html', 'max-age=1'); 165 get('/updating/t.html', 'max-age=1');
157 get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2'); 166 get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2');
158 get('/t8.html', 'stale-while-revalidate=10'); 167 get('/t8.html', 'stale-while-revalidate=10');
168 get('/escape.htm%6C', 'max-age=1, stale-while-revalidate=10');
169 get('/escape html', 'max-age=1, stale-while-revalidate=10');
159 170
160 sleep 2; 171 sleep 2;
161 172
162 like(http_get('/t.html?e=1'), qr/STALE/, 's-i-e - stale'); 173 like(http_get('/t.html?e=1'), qr/STALE/, 's-i-e - stale');
163 like(http_get('/tt.html?e=1'), qr/STALE/, 's-i-e - stale 2'); 174 like(http_get('/tt.html?e=1'), qr/STALE/, 's-i-e - stale 2');
233 # due to the missing content_handler inheritance in a cloned subrequest, 244 # due to the missing content_handler inheritance in a cloned subrequest,
234 # this used to access a static file in the update request 245 # this used to access a static file in the update request
235 246
236 like(http_get('/t2.html?if=1'), qr/STALE/, 'background update in if'); 247 like(http_get('/t2.html?if=1'), qr/STALE/, 'background update in if');
237 like(http_get('/t2.html?if=1'), qr/HIT/, 'background update in if - updated'); 248 like(http_get('/t2.html?if=1'), qr/HIT/, 'background update in if - updated');
249
250 # ticket #1430, uri escaping in cloned subrequests
251
252 $t->write_file('escape.html', 'SEE-THAT');
253 $t->write_file('escape html', 'SEE-THAT');
254
255 get('/escape.htm%6C', 'max-age=1');
256 get('/escape html', 'max-age=1');
257
258 TODO: {
259 local $TODO = 'not yet' unless $t->has_version('1.13.8');
260
261 like(http_get('/escape.htm%6C'), qr/HIT/, 'escaped after escaped');
262 like(http_get('/escape.html'), qr/MISS/, 'unescaped after escaped');
263 like(http_get('/escape html'), qr/HIT/, 'space after escaped space');
264
265 }
266
267 like(http_get('/escape%20html'), qr/HIT/, 'escaped space after escaped space');
238 268
239 ############################################################################### 269 ###############################################################################
240 270
241 sub get { 271 sub get {
242 my ($url, $extra, %extra) = @_; 272 my ($url, $extra, %extra) = @_;