CGI-Compress-Gzip

 view release on metacpan or  search on metacpan

t/gzip.t  view on Meta::CPAN

{
   local $TODO = 'Explicit use of filehandles not yet supported';

   my $out = `$basecmd -DHTTP_ACCEPT_ENCODING=gzip fh3 "$compare"`;
   msgs_match($out, $gzip . $compareheader . $zcompare, 'filehandle, explicit fh');
}

sub msgs_match {
   my ($got, $expected, $message) = @_;
   ## no critic (RegularExpressions::RequireLineBoundaryMatching)
   my ($got_head, $got_body) = split m/\015\012\015\012/xs, $got, 2;
   my ($exp_head, $exp_body) = split m/\015\012\015\012/xs, $expected, 2;
   my %exp = map {lc($_) => 1} split m/\015\012/xs, $exp_head;
   for my $got_head_line (split m/\015\012/xs, $got_head) {
      if (!delete $exp{lc $got_head_line}) {
         return is($got, $expected, $message . ' -- extra header: ' . $got_head_line); # fail
      }
   }
   if (scalar keys %exp) {
      return is($got, $expected, $message . ' -- missing header: ' . [keys %exp]->[0]); # fail
   }
   if ($got_body ne $exp_body) {
      return is($got, $expected, $message . ' -- bodies do not match'); # fail
   }



( run in 0.538 second using v1.01-cache-2.11-cpan-483215c6ad5 )