File: 51simple.t

package info (click to toggle)
libhttp-proxy-perl 0.301-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 636 kB
  • ctags: 164
  • sloc: perl: 2,403; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (10)
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
use Test::More tests => 3;
use strict;
use HTTP::Proxy::HeaderFilter::simple;
use HTTP::Headers;

my ( $filter, $sub, $h );

# error checking
eval { $filter = HTTP::Proxy::HeaderFilter::simple->new() };
like( $@, qr/^Constructor called without argument/, "Need at least one arg" );

eval { $filter = HTTP::Proxy::HeaderFilter::simple->new('foo') };
like( $@, qr/^Single parameter must be a CODE /, "Must pass a coderef" );

$sub = sub {
    my ( $self, $headers, $message ) = @_;
    $headers->header( User_Agent => 'Foo/1.0' );
};

$filter = HTTP::Proxy::HeaderFilter::simple->new($sub);

# test the filter
$h = HTTP::Headers->new(
    Date         => 'Thu, 03 Feb 1994 00:00:00 GMT',
    Content_Type => 'text/html; version=3.2',
    Content_Base => 'http://www.perl.org/'
);

$filter->filter( $h, undef );
is( $h->header('User-Agent'), 'Foo/1.0', "Header modified" );