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
|
|
482
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.904'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use parent 'HTTP::AnyUA::Middleware'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
64
|
use HTTP::AnyUA::Util; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
153
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub request { |
16
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
17
|
3
|
|
|
|
|
19
|
my ($method, $url, $args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
30
|
$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__ |