changeset 145:2ea7cd95ff05

Tests: basic tests for range requests from cache. Just to prevent regressions while getting rid of r->cache dependency in range filter.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 19 Jan 2011 06:20:11 +0300
parents 6e11354cae8a
children afa07ae9def6
files proxy-cache.t
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/proxy-cache.t
+++ b/proxy-cache.t
@@ -21,7 +21,7 @@ use Test::Nginx qw/ :DEFAULT :gzip /;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(10)
+my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(12)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -93,6 +93,10 @@ unlike(http_head('/t2.html'), qr/SEE-THI
 like(http_get('/t2.html'), qr/SEE-THIS/, 'get after head');
 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head after get');
 
+like(http_get_range('/t.html', 'Range: bytes=4-'), qr/^THIS/m, 'cached range');
+like(http_get_range('/t.html', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms,
+	'cached multipart range');
+
 like(http_get('/empty.html'), qr/HTTP/, 'empty get first');
 like(http_get('/empty.html'), qr/HTTP/, 'empty get second');
 
@@ -124,6 +128,19 @@ like(http_get('/fake/unfinished'), qr/un
 
 ###############################################################################
 
+sub http_get_range {
+        my ($url, $extra) = @_;
+        return http(<<EOF);
+GET $url HTTP/1.1
+Host: localhost
+Connection: close
+$extra
+
+EOF
+}
+
+###############################################################################
+
 sub http_fake_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',