line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Command::Wrapper::Wget; |
2
|
9
|
|
|
9
|
|
304185
|
use strict; |
|
9
|
|
|
|
|
41
|
|
|
9
|
|
|
|
|
242
|
|
3
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
220
|
|
4
|
9
|
|
|
9
|
|
46
|
use utf8; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
16
|
|
|
16
|
0
|
241860
|
my ($class, $opt) = @_; |
8
|
16
|
|
|
|
|
95
|
return bless { opt => $opt } => $class; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub fetch_able { |
12
|
4
|
|
|
4
|
0
|
13056
|
my ($self, $url, $headers) = @_; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
|
|
58
|
my $command = $self->_build($headers, 1, [ '--server-response', '--spider', qq/"$url"/ ]); |
15
|
4
|
|
|
|
|
68326
|
`$command 2>&1` =~ m/200 OK/; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub fetch { |
19
|
2
|
|
|
2
|
0
|
796
|
my ($self, $url, $headers) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
36
|
my $command = $self->_build($headers, 1, [ qq/"$url"/, '-O', '-' ]); |
22
|
2
|
|
|
|
|
32775
|
`$command`; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub download { |
26
|
2
|
|
|
2
|
0
|
2471
|
my ($self, $url, $path, $headers) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
26
|
my $command = $self->_build($headers, 0, [ '--continue', qq/"$url"/, '-O', qq/"$path"/ ]); |
29
|
2
|
|
|
|
|
100145
|
system($command) == 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _build { |
33
|
15
|
|
|
15
|
|
49
|
my ($self, $headers, $quiet, $opts) = @_; |
34
|
15
|
100
|
|
|
|
80
|
my @args = ( |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
35
|
|
|
|
|
|
|
'wget', |
36
|
|
|
|
|
|
|
$self->_headers($headers), |
37
|
|
|
|
|
|
|
$quiet ? undef : $self->_verbose, |
38
|
|
|
|
|
|
|
$quiet ? '--quiet' : $self->_quiet, |
39
|
|
|
|
|
|
|
defined $opts ? @$opts : undef, |
40
|
|
|
|
|
|
|
); |
41
|
15
|
|
|
|
|
38
|
return join(' ', grep { $_ } @args); |
|
79
|
|
|
|
|
180
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _headers { |
45
|
16
|
|
|
16
|
|
33
|
my ($self, $headers) = @_; |
46
|
16
|
100
|
|
|
|
198
|
return unless defined $headers; |
47
|
8
|
100
|
|
|
|
36
|
return if @$headers == 0; |
48
|
2
|
|
|
|
|
5
|
return map { "--header=\"$_\"" } @$headers; |
|
2
|
|
|
|
|
16
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _verbose { |
52
|
7
|
|
|
7
|
|
22
|
my $self = shift; |
53
|
7
|
100
|
|
|
|
53
|
return $self->{opt}->{verbose} ? '--verbose' : ''; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _quiet { |
57
|
7
|
|
|
7
|
|
11
|
my $self = shift; |
58
|
7
|
100
|
|
|
|
50
|
return $self->{opt}->{quiet} ? '--quiet' : ''; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |