changeset 101:6303927c18d2

Tests: proxy cache tests for problems with duplicate final chunks.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 02 Oct 2009 01:26:30 +0400
parents 9ddc18214854
children 9f723d3ba52d
files proxy-cache.t
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/proxy-cache.t
+++ b/proxy-cache.t
@@ -9,12 +9,12 @@
 use warnings;
 use strict;
 
-use Test::More tests => 7;
+use Test::More tests => 9;
 
 BEGIN { use FindBin; chdir($FindBin::Bin); }
 
 use lib 'lib';
-use Test::Nginx;
+use Test::Nginx qw/ :DEFAULT :gzip /;
 
 ###############################################################################
 
@@ -46,18 +46,22 @@ http {
         listen       127.0.0.1:8080;
         server_name  localhost;
 
+        gzip on;
+        gzip_min_length 0;
+
         location / {
             proxy_pass    http://127.0.0.1:8081;
 
             proxy_cache   NAME;
 
-            proxy_cache_valid   200 302  1h;
+            proxy_cache_valid   200 302  1s;
             proxy_cache_valid   301      1d;
             proxy_cache_valid   any      1m;
 
             proxy_cache_min_uses  1;
 
-            proxy_cache_use_stale   error  timeout invalid_header http_500;
+            proxy_cache_use_stale  error timeout invalid_header http_500
+                                   http_404;
         }
     }
     server {
@@ -91,6 +95,17 @@ like(http_get('/empty.html'), qr/HTTP/, 
 {
 local $TODO = 'not fixed yet';
 like(http_get('/empty.html'), qr/HTTP/, 'empty get second');
+
+sleep(2);
+unlink $t->testdir() . '/t.html';
+like(http_gzip_request('/t.html'),
+	qr/HTTP.*1c\x0d\x0a.{28}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s,
+	'non-empty get stale');
 }
 
+unlink $t->testdir() . '/empty.html';
+like(http_gzip_request('/empty.html'),
+	qr/HTTP.*14\x0d\x0a.{20}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s,
+	'empty get stale');
+
 ###############################################################################