HTTP/_EngineFactory.pm

filter: Statementstmt 100% 25 / 25 Branchbran 66.6% 8 / 12 Conditioncond 41.6% 5 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 68.8% 42 / 61 CC 11 SCAR 24.1
CC
11
Cov
78%
create
13.9
BEGIN
1.0
BEGIN
1.0
CRAP 11.2
« HTTP/_AltSvc.pm ↑ Summary HTTP/QUIC.pm »
1 package Unblock::HTTP::_EngineFactory;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 my %ENGINE = (
8 'http/1.1' => 'Unblock::HTTP1',
9 h2 => 'Unblock::HTTP2',
10 h3 => 'Unblock::HTTP3',
11 );
12  
13 91 ▶sub create {
Subroutine create: called CC=11 SCAR=26.3
Pod undocumented
14 91 my ($class, $role, $protocol, %options) = @_;
15 91 ▶ croak 'engine role must be Client or Server'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $role and $role eq "Client" || $role eq "Server" 0 91 91
Condition50%3/6
defined $role and $role eq "Client" || $role eq "Server"
!ll&&!rl&&r
0091
$role eq "Client" or $role eq "Server"
l!l&&r!l&&!r
78130
MC/DC0%0/3
defined $role and $role eq "Client" || $role eq "Server"
defined $role $role eq "Client" $role eq "Server"
Truth table50%2/4
A and B or C
A= defined $roleB= $role eq "Client"C= $role eq "Server"
ABCresult
0XX0
1000
11X1
1011
16 unless defined($role) && ($role eq 'Client' || $role eq 'Server');
17 91 ▶ croak 'protocol must be a scalar' unless defined($protocol) && !ref($protocol);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $protocol and not ref $protocol 0 91 91
Condition33%1/3
defined $protocol and not ref $protocol
!ll&&!rl&&r
0091
MC/DC0%0/2
defined $protocol and not ref $protocol
defined $protocol not ref $protocol
Truth table33%1/3
A and not(B)
A= defined $protocolB= not ref $protocol
ABresult
0X0
100
111
18 91 ▶ croak "unsupported HTTP protocol '$protocol'" unless exists $ENGINE{$protocol};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ENGINE{$protocol} 0 91 91
19 91 my $module = $ENGINE{$protocol} . '::' . $role;
20 91 (my $file = $module) =~ s{::}{/}g;
21 91 my $loaded = eval { require "$file.pm"; 1 };
22 91 ▶ croak "enabled HTTP protocol '$protocol' requires $module: $@" unless $loaded;
Branch: 1 branch
BranchTrueFalseTotal
unless $loaded 2 89 91
23 89 ▶ if ($role eq 'Server') {
Branch: 1 branch
BranchTrueFalseTotal
if ($role eq "Server") 13 76 89
24 13 my $transaction = $ENGINE{$protocol} . '::Transaction';
25 13 ▶ croak "$module needs the receive/lifecycle engine feature branch (on_data and on_finish)"
Branch: 1 branch
BranchTrueFalseTotal
unless $transaction->can("on_data") and $transaction->can("on_finish") 0 13 13
Condition33%1/3
$transaction->can("on_data") and $transaction->can("on_finish")
!ll&&!rl&&r
0013
MC/DC0%0/2
$transaction->can("on_data") and $transaction->can("on_finish")
$transaction->can("on_data") $transaction->can("on_finish")
Truth table33%1/3
A and B
A= $transaction->can("on_data")B= $transaction->can("on_finish")
ABresult
0X0
100
111
26 unless $transaction->can('on_data') && $transaction->can('on_finish');
27 }
28 89 return $module->new(%options);
29 }
30  
31 17 1;
« HTTP/_AltSvc.pm ↑ Summary HTTP/QUIC.pm »