blib/lib/Plack/LWPish.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 89.8% 44 / 49 CC 4 SCAR 5.5
CC
4
Cov
95%
request
3.0
new
2.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Plack/Middleware/SimpleLogger.pm ↑ Summary blib/lib/Plack/Middleware/SimpleContentFilter.pm »
1 package Plack::LWPish;
2 52 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 52 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 52 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 52 ▶use HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 52 ▶use Hash::MultiValue;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
9 17 my $class = shift;
10 17 my $self = bless {}, $class;
11 17 ▶ $self->{http} = @_ == 1 ? $_[0] : HTTP::Tiny->new(verify_SSL => 1, @_);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 17 17
12 17 $self;
13 }
14  
15 89 ▶sub request {
Subroutine request: called CC=3 SCAR=11.0
Pod undocumented
16 89 my($self, $req) = @_;
17  
18 89 my @headers;
19 89 ▶ $req->headers->scan(sub { push @headers, @_ });
Subroutine __ANON__: called CC=1 SCAR=0.0
20  
21 89 my $options = {
22 headers => Hash::MultiValue->new(@headers)->mixed,
23 };
24 89 ▶ $options->{content} = $req->content if defined $req->content && length($req->content);
Branch: 1 branch
BranchTrueFalseTotal
if defined $req->content and length $req->content 7 82 89
Condition66%2/3
defined $req->content and length $req->content
!ll&&!rl&&r
0827
MC/DC50%1/2
defined $req->content and length $req->content
defined $req->content length $req->content
Truth table66%2/3
A and B
A= defined $req->contentB= length $req->content
ABresult
0X0
100
111
25  
26 89 my $response = $self->{http}->request($req->method, $req->url, $options);
27  
28 my $res = HTTP::Response->new(
29 $response->{status},
30 $response->{reason},
31 [ Hash::MultiValue->from_mixed($response->{headers})->flatten ],
32 $response->{content},
33 89 );
34 89 $res->request($req);
35  
36 89 return $res;
37 }
38  
39 52 1;
40  
41 __END__
« blib/lib/Plack/Middleware/SimpleLogger.pm ↑ Summary blib/lib/Plack/Middleware/SimpleContentFilter.pm »