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