diff ssi-include-big.t @ 93:5276d85d5040

Tests: add basic gzip tests. This also includes clearing Accept-Ranges header got from upstream (broken since 0.7.44).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 26 May 2009 20:18:05 +0400
parents 726c3c2a8b8c
children 8bc9de6559a1
line wrap: on
line diff
--- a/ssi-include-big.t
+++ b/ssi-include-big.t
@@ -14,7 +14,7 @@ use Test::More;
 BEGIN { use FindBin; chdir($FindBin::Bin); }
 
 use lib 'lib';
-use Test::Nginx;
+use Test::Nginx qw/ :DEFAULT :gzip /;
 
 ###############################################################################
 
@@ -90,59 +90,4 @@ my $t4 = http_gzip_request('/test4.html'
 ok(defined $t4, 'big ssi main file');
 http_gzip_like($t4, qr/^X{1025}\Z/, 'big ssi main file content');
 
-
 ###############################################################################
-
-sub http_gzip_request {
-	my ($url) = @_;
-	my $r = http(<<EOF);
-GET $url HTTP/1.1
-Host: localhost
-Connection: close
-Accept-Encoding: gzip
-
-EOF
-}
-
-sub http_content {
-	my ($text) = @_;
-
-	return undef if !defined $text;
-
-	if ($text !~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms) {
-		return undef;
-	}
-
-	my ($headers, $body) = ($1, $2);
-
-	if ($headers !~ /Transfer-Encoding: chunked/i) {
-		return $body;
-	}
-
-	my $content = '';
-	while ($body =~ /\G\x0d?\x0a?([0-9a-f]+)\x0d\x0a?/gcmsi) {
-		my $len = hex($1);
-		$content .= substr($body, pos($body), $len);
-		pos($body) += $len;
-	}
-
-	return $content;
-}
-
-sub http_gzip_like {
-	my ($text, $re, $name) = @_;
-
-	SKIP: {
-		eval { require IO::Uncompress::Gunzip; };
-		skip "IO::Uncompress::Gunzip not installed", 1 if $@;
-
-		my $in = http_content($text);
-		my $out;
-
-		IO::Uncompress::Gunzip::gunzip(\$in => \$out);
-
-		like($out, $re, $name);
-	}
-}
-
-###############################################################################