line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Proxy::HeaderFilter::simple; |
2
|
|
|
|
|
|
|
$HTTP::Proxy::HeaderFilter::simple::VERSION = '0.303'; |
3
|
15
|
|
|
15
|
|
23059
|
use strict; |
|
15
|
|
|
|
|
15
|
|
|
15
|
|
|
|
|
377
|
|
4
|
15
|
|
|
15
|
|
38
|
use Carp; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
584
|
|
5
|
15
|
|
|
15
|
|
313
|
use HTTP::Proxy::HeaderFilter; |
|
15
|
|
|
|
|
13
|
|
|
15
|
|
|
|
|
210
|
|
6
|
15
|
|
|
15
|
|
37
|
use vars qw( @ISA ); |
|
15
|
|
|
|
|
15
|
|
|
15
|
|
|
|
|
3559
|
|
7
|
|
|
|
|
|
|
@ISA = qw( HTTP::Proxy::HeaderFilter ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $methods = join '|', qw( begin filter end ); |
10
|
|
|
|
|
|
|
$methods = qr/^(?:$methods)$/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
9
|
|
|
9
|
1
|
11
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
9
|
100
|
|
|
|
188
|
croak "Constructor called without argument" unless @_; |
16
|
8
|
50
|
|
|
|
31
|
if ( @_ == 1 ) { |
17
|
8
|
100
|
|
|
|
117
|
croak "Single parameter must be a CODE reference" |
18
|
|
|
|
|
|
|
unless ref $_[0] eq 'CODE'; |
19
|
7
|
|
|
|
|
47
|
$self->{_filter} = $_[0]; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
0
|
|
|
0
|
|
0
|
$self->{_filter} = sub { }; # default |
|
0
|
|
|
|
|
0
|
|
23
|
0
|
|
|
|
|
0
|
while (@_) { |
24
|
0
|
|
|
|
|
0
|
my ( $name, $code ) = splice @_, 0, 2; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# basic error checking |
27
|
0
|
0
|
|
|
|
0
|
croak "Parameter to $name must be a CODE reference" |
28
|
|
|
|
|
|
|
unless ref $code eq 'CODE'; |
29
|
0
|
0
|
|
|
|
0
|
croak "Unkown method $name" unless $name =~ $methods; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
$self->{"_$name"} = $code; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# transparently call the actual methods |
37
|
0
|
|
|
0
|
1
|
0
|
sub begin { goto &{ $_[0]{_begin} }; } |
|
0
|
|
|
|
|
0
|
|
38
|
4
|
|
|
4
|
1
|
94
|
sub filter { goto &{ $_[0]{_filter} }; } |
|
4
|
|
|
|
|
44
|
|
39
|
0
|
|
|
0
|
1
|
0
|
sub end { goto &{ $_[0]{_end} }; } |
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub can { |
42
|
15
|
|
|
15
|
1
|
32
|
my ( $self, $method ) = @_; |
43
|
15
|
100
|
|
|
|
231
|
return $method =~ $methods |
44
|
|
|
|
|
|
|
? $self->{"_$method"} |
45
|
|
|
|
|
|
|
: UNIVERSAL::can( $self, $method ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |