line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Squid::Purge::HTTP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1021
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw(Net::Squid::Purge); |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
83
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
864
|
use Net::HTTP; |
|
1
|
|
|
|
|
29847
|
|
|
1
|
|
|
|
|
100
|
|
9
|
1
|
|
|
1
|
|
1929
|
use HTTP::Status; |
|
1
|
|
|
|
|
4422
|
|
|
1
|
|
|
|
|
633
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::Squid::Purge::HTTP->mk_accessors(qw(squid_servers)); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub purge { |
16
|
0
|
|
|
0
|
1
|
|
my ($self, @urls) = @_; |
17
|
0
|
0
|
|
|
|
|
if (! $self->squid_servers) { die 'squid_servers must be set!'; } |
|
0
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
for my $squid_host (@{$self->squid_hosts}) { |
|
0
|
|
|
|
|
|
|
19
|
0
|
|
0
|
|
|
|
my $squid_host = Net::HTTP->new( |
20
|
|
|
|
|
|
|
Host => $squid_host->{'host'}, |
21
|
|
|
|
|
|
|
PeerPort => $squid_host->{'port'} || 3128, |
22
|
|
|
|
|
|
|
Timeout => 2, |
23
|
|
|
|
|
|
|
KeepAlive => 1, |
24
|
|
|
|
|
|
|
); |
25
|
0
|
0
|
|
|
|
|
if (! $squid_host) { warn "Could not connect to squid host $squid_host->{'host'}"; next; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
for my $url (@urls) { |
27
|
0
|
|
|
|
|
|
$squid_host->write_request($self->_format_purge($url)); |
28
|
0
|
|
|
|
|
|
my ($status, $message) = $squid_host->read_response_headers; |
29
|
0
|
0
|
|
|
|
|
if (! is_success($status)) { warn "Purge request failed: $message"; } |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
return 1; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _format_purge { |
36
|
0
|
|
|
0
|
|
|
my ($self, $url) = @_; |
37
|
0
|
0
|
|
|
|
|
if (! $url) { die 'url parameter must be passed'; } |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return ('PURGE', $url, 'Accept', '*/*'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |