Skip to content

Commit fe245ac

Browse files
committed
Tests: added uri escaping tests to proxy_cache_use_stale.t.
1 parent 82810a5 commit fe245ac

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

proxy_cache_use_stale.t

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ http {
5050
sendfile_max_chunk 4k;
5151
}
5252
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;
58+
}
59+
5360
location / {
5461
proxy_pass http://127.0.0.1:8081;
5562
@@ -134,8 +141,10 @@ $t->write_file('t6.html', 'SEE-THIS');
134141
$t->write_file('t7.html', 'SEE-THIS' x 1024);
135142
$t->write_file('t9.html', 'SEE-THIS' x 1024);
136143
$t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html" --> xxx');
144+
$t->write_file('escape.html', 'SEE-THIS');
145+
$t->write_file('escape html', 'SEE-THIS');
137146

138-
$t->run()->plan(29);
147+
$t->run()->plan(33);
139148

140149
###############################################################################
141150

@@ -156,6 +165,8 @@ http_get('/ssi.html');
156165
get('/updating/t.html', 'max-age=1');
157166
get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2');
158167
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');
159170

160171
sleep 2;
161172

@@ -236,6 +247,25 @@ $t->todo_alerts() if $t->read_file('nginx.conf') =~ /aio_write on/
236247
like(http_get('/t2.html?if=1'), qr/STALE/, 'background update in if');
237248
like(http_get('/t2.html?if=1'), qr/HIT/, 'background update in if - updated');
238249

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');
268+
239269
###############################################################################
240270

241271
sub get {

0 commit comments

Comments
 (0)