comparison h2.t @ 647:4e36550410b3

Tests: h2.t fixes for older perl versions, and gzip test.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 17 Aug 2015 17:15:44 +0300
parents 843a74ff43bc
children 8a2cf558b8ae
comparison
equal deleted inserted replaced
646:843a74ff43bc 647:4e36550410b3
771 771
772 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 772 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
773 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding'); 773 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding');
774 774
775 ($frame) = grep { $_->{type} eq "DATA" } @$frames; 775 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
776 is(gunzip($frame->{data}), 'SEE-THIS', 'gzip - DATA'); 776 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA');
777 777
778 # simple proxy cache test 778 # simple proxy cache test
779 779
780 $sess = new_session(); 780 $sess = new_session();
781 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' }); 781 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' });
1902 1902
1903 sub add { 1903 sub add {
1904 my ($h, $n, $v) = @_; 1904 my ($h, $n, $v) = @_;
1905 return $h->{$n} = $v unless exists $h->{$n}; 1905 return $h->{$n} = $v unless exists $h->{$n};
1906 $h->{$n} = [ $h->{$n} ]; 1906 $h->{$n} = [ $h->{$n} ];
1907 push $h->{$n}, $v; 1907 push @{$h->{$n}}, $v;
1908 } 1908 }
1909 1909
1910 while ($skip < $length) { 1910 while ($skip < $length) {
1911 my $ib = unpack("\@$skip B8", $data); 1911 my $ib = unpack("\@$skip B8", $data);
1912 1912
2234 return $ret; 2234 return $ret;
2235 } 2235 }
2236 2236
2237 ############################################################################### 2237 ###############################################################################
2238 2238
2239 sub gunzip { 2239 sub gunzip_like {
2240 my ($in) = @_; 2240 my ($in, $re, $name) = @_;
2241 2241
2242 SKIP: { 2242 SKIP: {
2243 eval { require IO::Uncompress::Gunzip; }; 2243 eval { require IO::Uncompress::Gunzip; };
2244 Test::More::skip( 2244 Test::More::skip(
2245 "IO::Uncompress::Gunzip not installed", 1) if $@; 2245 "IO::Uncompress::Gunzip not installed", 1) if $@;
2246 2246
2247 my $out; 2247 my $out;
2248 2248
2249 IO::Uncompress::Gunzip::gunzip(\$in => \$out); 2249 IO::Uncompress::Gunzip::gunzip(\$in => \$out);
2250 2250
2251 return $out; 2251 like($out, $re, $name);
2252 } 2252 }
2253 } 2253 }
2254 2254
2255 ############################################################################### 2255 ###############################################################################
2256 2256