File: gzip.t

package info (click to toggle)
libapache-filter-perl 1.024-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 248 kB
  • ctags: 62
  • sloc: perl: 901; makefile: 32
file content (49 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl

$|=1;
use strict;
use lib 't/lib';  # Until my changes are merged into the main distro
use Apache::test qw(skip_test have_httpd test);
use Test;

BEGIN {
  skip_test unless have_httpd;
  skip_test unless eval{require Apache::Compress};
  plan tests => 3;
}

my %requests = 
  (
   3  => '/docs/compress.cp',
   4  => {uri=>'/docs/compress.cp',
          headers=>{'Accept-Encoding' => 'gzip'},
         },
  );

my %special_tests = 
  (
   3  => { 'test' => sub { !defined($_[1]->header('Content-Encoding')) } },
   4  => { 'test' => sub { $_[1]->header('Content-Encoding') =~ /gzip/ } },
  );

ok(1); # Loaded successfully

foreach my $testnum (sort {$a<=>$b} keys %requests) {
  &test_outcome(Apache::test->fetch($requests{$testnum}), $testnum);
}

#############################

sub test_outcome {
  my ($response, $i) = @_;
  
  my $content = $response->content;
  $content = $special_tests{$i}{content}->($content, $response)
    if $special_tests{$i}{content};
  
  if ($special_tests{$i}{'test'}) {
    ok $special_tests{$i}{'test'}->($content, $response);
  } else {
    ok $content, scalar `cat t/docs.check/$i`;
  }
}