line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::AnyUA::Middleware::ContentLength; |
2
|
|
|
|
|
|
|
# ABSTRACT: Middleware to add Content-Length header automatically |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
472
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.903'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use parent 'HTTP::AnyUA::Middleware'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
43
|
use HTTP::AnyUA::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
133
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub request { |
16
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
17
|
3
|
|
|
|
|
18
|
my ($method, $url, $args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
28
|
$args->{headers} = HTTP::AnyUA::Util::normalize_headers($args->{headers}); |
20
|
|
|
|
|
|
|
|
21
|
3
|
100
|
66
|
|
|
20
|
if (!defined $args->{headers}{'content-length'} && $args->{content} && !ref $args->{content}) { |
|
|
|
100
|
|
|
|
|
22
|
1
|
|
|
|
|
3
|
$args->{headers}{'content-length'} = length $args->{content}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
8
|
return $self->backend->request($method, $url, $args); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |