line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Proxy::Engine; |
2
|
|
|
|
|
|
|
$HTTP::Proxy::Engine::VERSION = '0.303'; |
3
|
69
|
|
|
69
|
|
13653
|
use strict; |
|
69
|
|
|
|
|
76
|
|
|
69
|
|
|
|
|
1644
|
|
4
|
69
|
|
|
69
|
|
204
|
use Carp; |
|
69
|
|
|
|
|
71
|
|
|
69
|
|
|
|
|
10164
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my %engines = ( |
7
|
|
|
|
|
|
|
MSWin32 => 'NoFork', |
8
|
|
|
|
|
|
|
default => 'Legacy', |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# required accessors |
12
|
|
|
|
|
|
|
__PACKAGE__->make_accessors( qw( max_clients )); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
84
|
|
|
84
|
1
|
3511
|
my $class = shift; |
16
|
84
|
|
|
|
|
220
|
my %params = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# the front-end |
19
|
84
|
100
|
|
|
|
277
|
if ( $class eq 'HTTP::Proxy::Engine' ) { |
20
|
80
|
|
|
|
|
144
|
my $engine = delete $params{engine}; |
21
|
80
|
100
|
33
|
|
|
776
|
$engine = $engines{$^O} || $engines{default} |
22
|
|
|
|
|
|
|
unless defined $engine; |
23
|
|
|
|
|
|
|
|
24
|
80
|
|
|
|
|
132
|
$class = "HTTP::Proxy::Engine::$engine"; |
25
|
80
|
|
|
|
|
6023
|
eval "require $class"; |
26
|
80
|
100
|
|
|
|
1084
|
croak $@ if $@; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# some error checking |
30
|
83
|
100
|
|
|
|
627
|
croak "No proxy defined" |
31
|
|
|
|
|
|
|
unless exists $params{proxy}; |
32
|
80
|
100
|
|
|
|
795
|
croak "$params{proxy} is not a HTTP::Proxy object" |
33
|
|
|
|
|
|
|
unless UNIVERSAL::isa( $params{proxy}, 'HTTP::Proxy' ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# so we are an actual engine |
36
|
69
|
|
|
69
|
|
287
|
no strict 'refs'; |
|
69
|
|
|
|
|
69
|
|
|
69
|
|
|
|
|
8186
|
|
37
|
78
|
|
|
|
|
821
|
return bless { |
38
|
78
|
|
|
|
|
96
|
%{"$class\::defaults"}, |
39
|
|
|
|
|
|
|
%params |
40
|
|
|
|
|
|
|
}, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# run() should be defined in subclasses |
44
|
|
|
|
|
|
|
sub run { |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
0
|
|
|
|
|
0
|
my $class = ref $self; |
47
|
0
|
|
|
|
|
0
|
croak "$class doesn't define a run() method"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
230
|
|
|
230
|
1
|
1711
|
sub proxy { $_[0]{proxy} } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# class method |
53
|
|
|
|
|
|
|
sub make_accessors { |
54
|
137
|
|
|
137
|
1
|
219
|
my $class = shift; |
55
|
|
|
|
|
|
|
|
56
|
137
|
|
|
|
|
296
|
for my $attr (@_) { |
57
|
69
|
|
|
69
|
|
273
|
no strict 'refs'; |
|
69
|
|
|
|
|
92
|
|
|
69
|
|
|
|
|
4734
|
|
58
|
283
|
|
|
|
|
1167
|
*{"$class\::$attr"} = sub { |
59
|
564
|
100
|
|
564
|
|
7947
|
$_[0]{$attr} = $_[1] if defined $_[1]; |
60
|
564
|
|
|
|
|
3744
|
$_[0]{$attr}; |
61
|
283
|
|
|
|
|
637
|
}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |