line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Command::Wrapper::Wget; |
2
|
9
|
|
|
9
|
|
183891
|
use strict; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
204
|
|
3
|
9
|
|
|
9
|
|
26
|
use warnings; |
|
9
|
|
|
|
|
7
|
|
|
9
|
|
|
|
|
176
|
|
4
|
9
|
|
|
9
|
|
24
|
use utf8; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
16
|
|
|
16
|
0
|
136912
|
my ($class, $opt) = @_; |
8
|
16
|
|
|
|
|
75
|
return bless { opt => $opt } => $class; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub fetch_able { |
12
|
4
|
|
|
4
|
0
|
6885
|
my ($self, $url, $headers) = @_; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
|
|
19
|
my $command = $self->_build($headers, 1, [ '--server-response', '--spider', qq/"$url"/ ]); |
15
|
4
|
|
|
|
|
23997
|
`$command 2>&1` =~ m/200 OK/; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub fetch { |
19
|
2
|
|
|
2
|
0
|
522
|
my ($self, $url, $headers) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
12
|
my $command = $self->_build($headers, 1, [ qq/"$url"/, '-O', '-' ]); |
22
|
2
|
|
|
|
|
13738
|
`$command`; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub download { |
26
|
2
|
|
|
2
|
0
|
1418
|
my ($self, $url, $path, $headers) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
18
|
my $command = $self->_build($headers, 0, [ '--continue', qq/"$url"/, '-O', qq/"$path"/ ]); |
29
|
2
|
|
|
|
|
15364
|
system($command) == 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _build { |
33
|
15
|
|
|
15
|
|
32
|
my ($self, $headers, $quiet, $opts) = @_; |
34
|
15
|
100
|
|
|
|
27
|
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
|
|
|
|
|
23
|
return join(' ', grep { $_ } @args); |
|
79
|
|
|
|
|
164
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _headers { |
45
|
16
|
|
|
16
|
|
24
|
my ($self, $headers) = @_; |
46
|
16
|
100
|
|
|
|
89
|
return unless defined $headers; |
47
|
8
|
100
|
|
|
|
29
|
return if @$headers == 0; |
48
|
2
|
|
|
|
|
3
|
return map { "--header=\"$_\"" } @$headers; |
|
2
|
|
|
|
|
11
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _verbose { |
52
|
7
|
|
|
7
|
|
7
|
my $self = shift; |
53
|
7
|
100
|
|
|
|
33
|
return $self->{opt}->{verbose} ? '--verbose' : ''; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _quiet { |
57
|
7
|
|
|
7
|
|
5
|
my $self = shift; |
58
|
7
|
100
|
|
|
|
35
|
return $self->{opt}->{quiet} ? '--quiet' : ''; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |