diff proxy_cache.t @ 299:44c42894fdfd

Tests: move unfinished tests to a separate file. Add more tests to catch unfinished chunked responses, as well as proxy-only aspect of the problem (we shouldn't send final chunk if we know the response isn't complete).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 11 Jun 2013 17:14:37 +0400
parents 6fe0459b6668
children e402c5ed57eb
line wrap: on
line diff
--- a/proxy_cache.t
+++ b/proxy_cache.t
@@ -23,7 +23,7 @@ select STDOUT; $| = 1;
 
 plan(skip_all => 'win32') if $^O eq 'MSWin32';
 
-my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(12)
+my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(11)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -60,11 +60,6 @@ http {
             proxy_cache_use_stale  error timeout invalid_header http_500
                                    http_404;
         }
-
-        location /fake/ {
-            proxy_pass    http://127.0.0.1:8082;
-            proxy_cache   NAME;
-        }
     }
     server {
         listen       127.0.0.1:8081;
@@ -81,8 +76,7 @@ EOF
 $t->write_file('t2.html', 'SEE-THIS');
 $t->write_file('empty.html', '');
 
-$t->run_daemon(\&http_fake_daemon);
-$t->run()->waitforsocket('127.0.0.1:8081');
+$t->run();
 
 ###############################################################################
 
@@ -113,9 +107,6 @@ like(http_gzip_request('/empty.html'),
 	qr/HTTP.*14\x0d\x0a.{20}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s,
 	'empty get stale');
 
-http_get('/fake/unfinished');
-like(http_get('/fake/unfinished'), qr/unfinished 2/, 'unfinished not cached');
-
 ###############################################################################
 
 sub http_get_range {
@@ -130,37 +121,3 @@ EOF
 }
 
 ###############################################################################
-
-sub http_fake_daemon {
-	my $server = IO::Socket::INET->new(
-		Proto => 'tcp',
-		LocalAddr => '127.0.0.1:8082',
-		Listen => 5,
-		Reuse => 1
-	)
-		or die "Can't create listening socket: $!\n";
-
-	local $SIG{PIPE} = 'IGNORE';
-
-	my $num = 0;
-
-	while (my $client = $server->accept()) {
-		$client->autoflush(1);
-
-		while (<$client>) {
-			last if (/^\x0d?\x0a?$/);
-		}
-
-		$num++;
-		print $client <<"EOF";
-HTTP/1.1 200 OK
-Content-Length: 100
-Cache-Control: max-age=300
-Connection: close
-
-unfinished $num
-EOF
-	}
-}
-
-###############################################################################