line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::AnyUA::Middleware::RequestHeaders; |
2
|
|
|
|
|
|
|
# ABSTRACT: Middleware to add custom request headers |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
461
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.903'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use parent 'HTTP::AnyUA::Middleware'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
41
|
use HTTP::AnyUA::Util; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
210
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub init { |
16
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
17
|
2
|
|
|
|
|
5
|
my %args = @_; |
18
|
2
|
|
|
|
|
9
|
$self->{override} = !!$args{override}; |
19
|
2
|
|
|
|
|
7
|
$self->{headers} = HTTP::AnyUA::Util::normalize_headers($args{headers}); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub request { |
23
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
24
|
3
|
|
|
|
|
7
|
my ($method, $url, $args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
5
|
if ($self->override) { |
27
|
|
|
|
|
|
|
$args->{headers} = { |
28
|
1
|
|
|
|
|
3
|
%{HTTP::AnyUA::Util::normalize_headers($args->{headers})}, |
29
|
1
|
|
|
|
|
2
|
%{$self->headers}, |
|
1
|
|
|
|
|
3
|
|
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
|
|
|
|
|
|
$args->{headers} = { |
34
|
2
|
|
|
|
|
3
|
%{$self->headers}, |
35
|
2
|
|
|
|
|
4
|
%{HTTP::AnyUA::Util::normalize_headers($args->{headers})}, |
|
2
|
|
|
|
|
6
|
|
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
13
|
return $self->backend->request($method, $url, $args); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
1
|
10
|
sub headers { shift->{headers} } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
1
|
8
|
sub override { shift->{override} } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |