| 1 | package Unblock::HTTP::_Policy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | my %NAME = ('http/1.1' => 'http1', h2 => 'http2', h3 => 'http3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | my @PROTOCOLS = ('http/1.1', 'h2', 'h3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 82 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=42 SCAR=40.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 82 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 82 | my $websocket_role = delete $options{_websocket_role}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 82 | ▶ | croak 'invalid internal WebSocket policy role' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $websocket_role and $websocket_role ne "server" and $websocket_role ne "client"
defined $websocket_role and $websocket_role ne "server"
MC/DC0%0/3
defined $websocket_role and $websocket_role ne "server" and $websocket_role ne "client"
defined $websocket_role
$websocket_role ne "server"
$websocket_role ne "client"
Truth table50%2/4
A and B and C
A= defined $websocket_roleB= $websocket_role ne "server"C= $websocket_role ne "client"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | if defined($websocket_role) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | && $websocket_role ne 'server' && $websocket_role ne 'client'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 82 | my (%engines, %websocket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 82 | for my $protocol (@PROTOCOLS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 232 | my $name = $NAME{$protocol}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 232 | ▶ | next unless exists $options{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 89 | my $config = delete $options{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 89 | ▶ | croak "$name must be a hash reference; omit it to disable the protocol" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | unless ref($config) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 86 | $config = _copy($config); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $websocket = exists($config->{websocket}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 85 | ▶ | ? delete $config->{websocket} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 85 | ▶ | croak "$name websocket must be 0 or 1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $websocket and not ref $websocket and "$websocket" =~ /\A[01]\z/
defined $websocket and not ref $websocket
MC/DC33%1/3
defined $websocket and not ref $websocket and "$websocket" =~ /\A[01]\z/
defined $websocket
not ref $websocket
"$websocket" =~ /\A[01]\z/
Truth table50%2/4
A and not(B) and C
A= defined $websocketB= not ref $websocketC= "$websocket" =~ /\A[01]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | unless defined($websocket) && !ref($websocket) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | && "$websocket" =~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 84 | ▶ | if ($websocket) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | croak "$name WebSocket attachment is not implemented yet; see docs/IMPLEMENTATION.md" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $websocket_role and $protocol eq "http/1.1" || $protocol eq "h2" || $protocol eq "h3"
$protocol eq "http/1.1" or $protocol eq "h2" or $protocol eq "h3"
$protocol eq "http/1.1" or $protocol eq "h2"
MC/DC0%0/4
defined $websocket_role and $protocol eq "http/1.1" || $protocol eq "h2" || $protocol eq "h3"
defined $websocket_role
$protocol eq "http/1.1"
$protocol eq "h2"
$protocol eq "h3"
Truth table60%3/5
A and B or C or D
A= defined $websocket_roleB= $protocol eq "http/1.1"C= $protocol eq "h2"D= $protocol eq "h3"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | unless defined($websocket_role) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | && ($protocol eq 'http/1.1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | || $protocol eq 'h2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | || $protocol eq 'h3'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | $websocket{$protocol} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 84 | for my $key (keys %$config) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | croak "$name option '$key' is managed by Unblock::HTTP" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key =~ /\Aon_/ or $key =~ /\A(?:transport|quic|protocol|alpn|receive_body)\z/
MC/DC100%2/2
$key =~ /\Aon_/ or $key =~ /\A(?:transport|quic|protocol|alpn|receive_body)\z/
$key =~ /\Aon_/
$key =~ /\A(?:transport|quic|protocol|alpn|receive_body)\z/
Truth table100%3/3
A or B
A= $key =~ /\Aon_/B= $key =~ /\A(?:transport|quic|protocol|alpn|receive_body)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | if $key =~ /\Aon_/ || $key =~ /\A(?:transport|quic|protocol|alpn|receive_body)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 81 | $config->{receive_body} = 'buffered'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $config->{max_buffered_body_bytes} = 1_048_576 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 81 | ▶ | unless exists $config->{max_buffered_body_bytes}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | croak "$name max_buffered_body_bytes must be a positive integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | unless defined($config->{max_buffered_body_bytes}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | && !ref($config->{max_buffered_body_bytes}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | && $config->{max_buffered_body_bytes} =~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | && $config->{max_buffered_body_bytes} > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 81 | ▶ | && $config->{max_buffered_body_bytes} <= (~0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%6/12
defined $config->{"max_buffered_body_bytes"} and not ref $config->{"max_buffered_body_bytes"} and $config->{"max_buffered_body_bytes"} =~ /\A[0-9]+\z/ and $config->{"max_buffered_body_bytes"} > 0 and $config->{"max_buffered_body_bytes"} <= '18446744073709551615'
defined $config->{"max_buffered_body_bytes"} and not ref $config->{"max_buffered_body_bytes"} and $config->{"max_buffered_body_bytes"} =~ /\A[0-9]+\z/ and $config->{"max_buffered_body_bytes"} > 0
defined $config->{"max_buffered_body_bytes"} and not ref $config->{"max_buffered_body_bytes"} and $config->{"max_buffered_body_bytes"} =~ /\A[0-9]+\z/
defined $config->{"max_buffered_body_bytes"} and not ref $config->{"max_buffered_body_bytes"}
MC/DC20%1/5
defined $config->{"max_buffered_body_bytes"} and not ref $config->{"max_buffered_body_bytes"} and $config->{"max_buffered_body_bytes"} =~ /\A[0-9]+\z/ and $config->{"max_buffered_body_bytes"} > 0 and $config->{"max_buffered_body_bytes"} <= '18446744073709551615'
defined $config->{"max_buffered_body_bytes"}
not ref $config->{"max_buffered_body_bytes"}
$config->{"max_buffered_body_bytes"} =~ /\A[0-9]+\z/
$config->{"max_buffered_body_bytes"} > 0
$config->{"max_buffered_body_bytes"} <= '18446744073709551615'
Truth table33%2/6
A and not(B) and C and D and E
A= defined $config->{"max_buffered_body_bytes"}B= not ref $config->{"max_buffered_body_bytes"}C= $config->{"max_buffered_body_bytes"} =~ /\A[0-9]+\z/D= $config->{"max_buffered_body_bytes"} > 0E= $config->{"max_buffered_body_bytes"} <= '18446744073709551615'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 80 | ▶ | if ($protocol eq 'h2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 20 | ▶ | if (exists $config->{settings}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | croak 'http2 settings must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | unless ref($config->{settings}) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 19 | ▶ | if ($websocket) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | croak 'http2 WebSocket requires enable_connect_protocol => 1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | if exists($config->{enable_connect_protocol}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | && !$config->{enable_connect_protocol}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $config->{"enable_connect_protocol"} and not $config->{"enable_connect_protocol"}
MC/DC0%0/2
exists $config->{"enable_connect_protocol"} and not $config->{"enable_connect_protocol"}
exists $config->{"enable_connect_protocol"}
not $config->{"enable_connect_protocol"}
Truth table33%1/3
A and not(B)
A= exists $config->{"enable_connect_protocol"}B= not $config->{"enable_connect_protocol"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | croak 'http2 WebSocket conflicts with settings 8 => 0' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | if exists($config->{settings}) && exists($config->{settings}{8}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | && !$config->{settings}{8}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $config->{"settings"} and exists $config->{"settings"}{8} and not $config->{"settings"}{8}
exists $config->{"settings"} and exists $config->{"settings"}{8}
MC/DC0%0/3
exists $config->{"settings"} and exists $config->{"settings"}{8} and not $config->{"settings"}{8}
exists $config->{"settings"}
exists $config->{"settings"}{8}
not $config->{"settings"}{8}
Truth table25%1/4
A and B and not(C)
A= exists $config->{"settings"}B= exists $config->{"settings"}{8}C= not $config->{"settings"}{8}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | $config->{enable_connect_protocol} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Generic Extended CONNECT is valid without WebSocket. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # Caller must opt into SETTINGS_ENABLE_CONNECT_PROTOCOL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $config->{enable_connect_protocol} = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 18 | ▶ | unless exists $config->{enable_connect_protocol}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 79 | ▶ | if ($protocol eq 'h3') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 19 | ▶ | if ($websocket) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | croak 'http3 WebSocket requires enable_extended_connect => 1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | if exists($config->{enable_extended_connect}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | && !$config->{enable_extended_connect}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $config->{"enable_extended_connect"} and not $config->{"enable_extended_connect"}
MC/DC0%0/2
exists $config->{"enable_extended_connect"} and not $config->{"enable_extended_connect"}
exists $config->{"enable_extended_connect"}
not $config->{"enable_extended_connect"}
Truth table33%1/3
A and not(B)
A= exists $config->{"enable_extended_connect"}B= not $config->{"enable_extended_connect"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | $config->{enable_extended_connect} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # RFC 9220 WebSocket is only one Extended CONNECT use. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $config->{enable_extended_connect} = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 18 | ▶ | unless exists $config->{enable_extended_connect}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 79 | $engines{$protocol} = $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 72 | ▶ | croak 'unknown protocol option: ' . join(', ', sort keys %options) if %options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 72 | ▶ | croak 'enable at least one of http1, http2, or http3' unless keys %engines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 71 | return bless { engines => \%engines, websocket => \%websocket }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | ▶ | sub protocols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocols: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | return grep { exists $self->{engines}{$_} } @PROTOCOLS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 54 | ▶ | sub alpn_protocols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alpn_protocols: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 54 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 54 | return grep { exists $self->{engines}{$_} } ('h2', 'http/1.1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2226 | ▶ | sub enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enabled: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2226 | my ($self, $protocol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | return defined($protocol) && !ref($protocol) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2226 | ▶ | && exists($self->{engines}{$protocol}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $protocol and not ref $protocol and exists $self->{"engines"}{$protocol}
defined $protocol and not ref $protocol
MC/DC100%3/3
defined $protocol and not ref $protocol and exists $self->{"engines"}{$protocol}
defined $protocol
not ref $protocol
exists $self->{"engines"}{$protocol}
Truth table100%4/4
A and not(B) and C
A= defined $protocolB= not ref $protocolC= exists $self->{"engines"}{$protocol}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 59 | ▶ | sub websocket_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
websocket_enabled: called CC=4 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 59 | my ($self, $protocol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | return defined($protocol) && !ref($protocol) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 59 | ▶ | && $self->{websocket}{$protocol} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $protocol and not ref $protocol and $self->{"websocket"}{$protocol}
defined $protocol and not ref $protocol
MC/DC33%1/3
defined $protocol and not ref $protocol and $self->{"websocket"}{$protocol}
defined $protocol
not ref $protocol
$self->{"websocket"}{$protocol}
Truth table50%2/4
A and not(B) and C
A= defined $protocolB= not ref $protocolC= $self->{"websocket"}{$protocol}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 95 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 95 | my ($self, $protocol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 95 | ▶ | croak "HTTP protocol '$protocol' is disabled" unless $self->enabled($protocol); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 92 | return _copy($self->{engines}{$protocol}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # Copy configuration containers at construction and attachment. Host objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # and callbacks retain their identity; no copying happens on the byte path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 428 | ▶ | sub _copy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_copy: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 428 | my ($value, $active) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 428 | ▶ | return $value unless ref($value) eq 'HASH' || ref($value) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $value eq "HASH" or ref $value eq "ARRAY"
MC/DC100%2/2
ref $value eq "HASH" or ref $value eq "ARRAY"
ref $value eq "HASH"
ref $value eq "ARRAY"
Truth table100%3/3
A or B
A= ref $value eq "HASH"B= ref $value eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 183 | ▶ | $active ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$active ||= {}
MC/DC100%1/1
$active ||= {}
$active
Truth table100%2/2
A
A= $active
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 183 | my $id = refaddr($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | croak 'protocol configuration must not contain circular containers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 183 | ▶ | if $active->{$id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 182 | local $active->{$id} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 182 | ▶ | return { map { $_ => _copy($value->{$_}, $active) } keys %$value } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | if ref($value) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return [ map { _copy($_, $active) } @$value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||