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