| 1 | package HTTP::AnyUA::Middleware::ContentLength; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Middleware to add Content-Length header automatically | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | our $VERSION = '0.904'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use parent 'HTTP::AnyUA::Middleware'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use HTTP::AnyUA::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | sub request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my ($method, $url, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | $args->{headers} = HTTP::AnyUA::Util::normalize_headers($args->{headers}); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | if (!defined $args->{headers}{'content-length'} && $args->{content} && !ref $args->{content}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $args->{"headers"}{"content-length"} and $args->{"content"} and not ref $args->{"content"}
not defined $args->{"headers"}{"content-length"} and $args->{"content"}
MC/DC66%2/3
not defined $args->{"headers"}{"content-length"} and $args->{"content"} and not ref $args->{"content"}
not defined $args->{"headers"}{"content-length"}
$args->{"content"}
not ref $args->{"content"}
Truth table75%3/4
not(A) and B and not(C)
A= not defined $args->{"headers"}{"content-length"}B= $args->{"content"}C= not ref $args->{"content"}
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | $args->{headers}{'content-length'} = length $args->{content}; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | return $self->backend->request($method, $url, $args); | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | __END__ | ||||||||||||||||||||||||||||||||||||||||||