1use Test::More tests => 3;
2use strict;
3use HTTP::Proxy::HeaderFilter::simple;
4use HTTP::Headers;
5
6my ( $filter, $sub, $h );
7
8# error checking
9eval { $filter = HTTP::Proxy::HeaderFilter::simple->new() };
10like( $@, qr/^Constructor called without argument/, "Need at least one arg" );
11
12eval { $filter = HTTP::Proxy::HeaderFilter::simple->new('foo') };
13like( $@, qr/^Single parameter must be a CODE /, "Must pass a coderef" );
14
15$sub = sub {
16    my ( $self, $headers, $message ) = @_;
17    $headers->header( User_Agent => 'Foo/1.0' );
18};
19
20$filter = HTTP::Proxy::HeaderFilter::simple->new($sub);
21
22# test the filter
23$h = HTTP::Headers->new(
24    Date         => 'Thu, 03 Feb 1994 00:00:00 GMT',
25    Content_Type => 'text/html; version=3.2',
26    Content_Base => 'http://www.perl.org/'
27);
28
29$filter->filter( $h, undef );
30is( $h->header('User-Agent'), 'Foo/1.0', "Header modified" );
31
32