| 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
Condition50%3/6
defined $role and $role eq "Client" || $role eq "Server"
$role eq "Client" or $role eq "Server"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
defined $protocol and not ref $protocol
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
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 91 | ▶ | croak "unsupported HTTP protocol '$protocol'" unless exists $ENGINE{$protocol}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 89 | ▶ | if ($role eq 'Server') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$transaction->can("on_data") and $transaction->can("on_finish")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | unless $transaction->can('on_data') && $transaction->can('on_finish'); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 89 | return $module->new(%options); | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||