# HG changeset patch # User Roman Arutyunyan # Date 1597401147 -10800 # Node ID 17b227c271a29d7ed59f4cf609eb097af37488c3 # Parent e145509cc6ebd089dc4adffca3999bbce941355a Tests: 4xx and 5xx codes with stale-while-revalidate. Now these codes do not fall under stale-if-error (enabled by stale-while-revalidate). diff --git a/proxy_cache_use_stale.t b/proxy_cache_use_stale.t --- a/proxy_cache_use_stale.t +++ b/proxy_cache_use_stale.t @@ -151,7 +151,7 @@ EOF $t->write_file('escape html', 'SEE-THIS'); $t->write_file('regexp.html', 'SEE-THIS'); -$t->run()->plan(35); +$t->run()->plan(36); ############################################################################### @@ -171,6 +171,7 @@ get('/t7.html', 'max-age=1, stale-while- http_get('/ssi.html'); get('/updating/t.html', 'max-age=1'); get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2'); +get('/updating/tt.html', 'max-age=1, stale-if-error=5'); get('/t8.html', 'stale-while-revalidate=10'); get('/escape.htm%6C', 'max-age=1, stale-while-revalidate=10'); get('/escape html', 'max-age=1, stale-while-revalidate=10'); @@ -178,8 +179,18 @@ get('/regexp.html', 'max-age=1, stale-wh sleep 2; -like(http_get('/t.html?e=1'), qr/STALE/, 's-i-e - stale'); -like(http_get('/tt.html?e=1'), qr/STALE/, 's-i-e - stale 2'); +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.19.3'); + +# stale 5xx response is ignored since 1.19.3, +# "proxy_cache_use_stale updating;" allows to get it still + +like(http_get('/t.html?e=1'), qr/ 500 /, 's-i-e - stale 5xx ignore'); +like(http_get('/tt.html?e=1'), qr/ 500 /, 's-i-e - stale 5xx ignore 2'); + +} + +like(http_get('/updating/tt.html'), qr/STALE/, 's-i-e - stale 5xx updating'); like(http_get('/t.html'), qr/REVALIDATED/, 's-i-e - revalidated'); like(http_get('/t2.html?e=1'), qr/STALE/, 's-w-r - revalidate error'); @@ -190,8 +201,14 @@ like(get('/t4.html', 'max-age=1, stale-w 's-w-r - unconditional revalidate'); like(http_get('/t4.html'), qr/HIT/, 's-w-r - unconditional revalidated'); -like(http_get('/t5.html?e=1'), qr/STALE/, +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.19.3'); + +like(http_get('/t5.html?e=1'), qr/ 500 /, 's-w-r - foreground revalidate error'); + +} + like(http_get('/t5.html'), qr/REVALIDATED/, 's-w-r - foreground revalidated'); # proxy_pass to regular expression with named and positional captures