| 1 | package Unblock::WebSocket::_Deflate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 15 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Compress::Raw::Zlib 2.017 qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | Z_BUF_ERROR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | Z_HUFFMAN_ONLY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Z_OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | Z_SYNC_FLUSH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 15 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 15 | my $TAIL = "\x00\x00\xff\xff"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 31 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=24 SCAR=36.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 31 | my ($class, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 31 | my $role = delete $option{role}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 31 | ▶ | croak 'new(): 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | unless defined($role) && ($role eq 'client' || $role eq 'server'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 31 | my $config = delete $option{config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 31 | ▶ | croak 'new(): config must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | unless ref($config) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 31 | my $max_message_size = delete $option{max_message_size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 31 | ▶ | croak 'new(): max_message_size must be a positive integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $max_message_size and not ref $max_message_size and $max_message_size =~ /\A[0-9]+\z/ and $max_message_size > 0
defined $max_message_size and not ref $max_message_size and $max_message_size =~ /\A[0-9]+\z/
defined $max_message_size and not ref $max_message_size
MC/DC0%0/4
defined $max_message_size and not ref $max_message_size and $max_message_size =~ /\A[0-9]+\z/ and $max_message_size > 0
defined $max_message_size
not ref $max_message_size
$max_message_size =~ /\A[0-9]+\z/
$max_message_size > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $max_message_sizeB= not ref $max_message_sizeC= $max_message_size =~ /\A[0-9]+\z/D= $max_message_size > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | unless defined($max_message_size) && !ref($max_message_size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | && $max_message_size =~ /\A[0-9]+\z/ && $max_message_size > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 31 | ▶ | croak 'new(): unknown option(s): ' . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | my $out_bits = $role eq 'client' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ? ($config->{client_max_window_bits} || 15) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 31 | ▶ | : ($config->{server_max_window_bits} || 15); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%4/4
$config->{"client_max_window_bits"} or 15
$config->{"server_max_window_bits"} or 15
MC/DC100%1/1
$config->{"client_max_window_bits"} or 15
$config->{"client_max_window_bits"}
MC/DC100%1/1
$config->{"server_max_window_bits"} or 15
$config->{"server_max_window_bits"}
Truth table100%2/2
A
A= $config->{"client_max_window_bits"}
Truth table100%2/2
A
A= $config->{"server_max_window_bits"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 31 | ▶ | croak 'permessage-deflate compressor window must be between 8 and 15' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$out_bits < 8 or $out_bits > 15
MC/DC0%0/2
$out_bits < 8 or $out_bits > 15
$out_bits < 8
$out_bits > 15
Truth table33%1/3
A or B
A= $out_bits < 8B= $out_bits > 15
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | if $out_bits < 8 || $out_bits > 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | my $in_bits = $role eq 'client' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ? ($config->{server_max_window_bits} || 15) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 31 | ▶ | : ($config->{client_max_window_bits} || 15); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%4/4
$config->{"server_max_window_bits"} or 15
$config->{"client_max_window_bits"} or 15
MC/DC100%1/1
$config->{"server_max_window_bits"} or 15
$config->{"server_max_window_bits"}
MC/DC100%1/1
$config->{"client_max_window_bits"} or 15
$config->{"client_max_window_bits"}
Truth table100%2/2
A
A= $config->{"server_max_window_bits"}
Truth table100%2/2
A
A= $config->{"client_max_window_bits"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 31 | ▶ | croak 'permessage-deflate inflater window must be between 8 and 15' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$in_bits < 8 or $in_bits > 15
MC/DC0%0/2
$in_bits < 8 or $in_bits > 15
$in_bits < 8
$in_bits > 15
Truth table33%1/3
A or B
A= $in_bits < 8B= $in_bits > 15
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | if $in_bits < 8 || $in_bits > 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | my $out_no_context = $role eq 'client' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ? $config->{client_no_context_takeover} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 31 | ▶ | : $config->{server_no_context_takeover}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | my $in_no_context = $role eq 'client' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ? $config->{server_no_context_takeover} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 31 | ▶ | : $config->{client_no_context_takeover}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 31 | ▶ | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | role => $role, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | config => { %$config }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | max_message_size => 0 + $max_message_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | out_bits => 0 + $out_bits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | in_bits => 0 + $in_bits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | out_no_context => $out_no_context ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | in_no_context => $in_no_context ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | deflater => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | inflater => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | ▶ | sub _new_deflater { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_deflater: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 20 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | my %option = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | -WindowBits => -$self->{out_bits}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 20 | -AppendOutput => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # zlib promotes an 8-bit deflate window to 9 internally. For an RFC 7692 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # window of 8, use a 9-bit raw stream with Huffman-only compression. That | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # emits no LZ77 distance references, so the stream is valid for a peer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # constrained to a 256-byte window. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 20 | ▶ | if ($self->{out_bits} == 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | $option{-WindowBits} = -9; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | $option{-Strategy} = Z_HUFFMAN_ONLY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 20 | my ($z, $status) = Compress::Raw::Zlib::Deflate->new(%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 20 | ▶ | croak "permessage-deflate deflater initialization failed: $status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$z and $status == Z_OK()
MC/DC0%0/2
$z and $status == Z_OK()
$z
$status == Z_OK()
Truth table33%1/3
A and B
A= $zB= $status == Z_OK()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | unless $z && $status == Z_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 20 | return $z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 15 | ▶ | sub _new_inflater { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_inflater: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 15 | my $bufsize = $self->{max_message_size} + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 15 | ▶ | $bufsize = 64 * 1024 if $bufsize > 64 * 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | my ($z, $status) = Compress::Raw::Zlib::Inflate->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | -WindowBits => -$self->{in_bits}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 15 | -LimitOutput => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | -Bufsize => $bufsize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | -AppendOutput => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 15 | ▶ | croak "permessage-deflate inflater initialization failed: $status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$z and $status == Z_OK()
MC/DC0%0/2
$z and $status == Z_OK()
$z
$status == Z_OK()
Truth table33%1/3
A and B
A= $zB= $status == Z_OK()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | unless $z && $status == Z_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 15 | return $z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 22 | ▶ | sub compress { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compress: called CC=10 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 22 | my ($self, $payload) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 22 | ▶ | croak 'compress(): payload must be a defined scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $payload or ref $payload
MC/DC0%0/2
not defined $payload or ref $payload
not defined $payload
ref $payload
Truth table33%1/3
not(A) or B
A= not defined $payloadB= ref $payload
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | if !defined($payload) || ref($payload); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 22 | my $bytes = "$payload"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 22 | ▶ | croak 'compress(): payload must be a byte string' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | unless utf8::downgrade($bytes, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 22 | ▶ | my $z = $self->{deflater} ||= $self->_new_deflater; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"deflater"} ||= $self->_new_deflater
MC/DC0%0/2
$self->{"deflater"} ||= $self->_new_deflater
$self->{"deflater"}
$self->_new_deflater
Truth table66%2/3
A ||= B
A= $self->{"deflater"}B= $self->_new_deflater
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 22 | my $output = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 22 | my $status = $z->deflate($bytes, $output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 22 | ▶ | croak "permessage-deflate compression failed: $status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | unless $status == Z_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 22 | $status = $z->flush($output, Z_SYNC_FLUSH); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 22 | ▶ | croak "permessage-deflate sync flush failed: $status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | unless $status == Z_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 22 | ▶ | croak 'permessage-deflate compressor produced an invalid sync-flush tail' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $output < 4 or substr($output, -4) ne $TAIL
MC/DC0%0/2
length $output < 4 or substr($output, -4) ne $TAIL
length $output < 4
substr($output, -4) ne $TAIL
Truth table33%1/3
A or B
A= length $output < 4B= substr($output, -4) ne $TAIL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | if length($output) < 4 || substr($output, -4) ne $TAIL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 22 | substr($output, -4, 4, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 22 | ▶ | $self->{deflater} = undef if $self->{out_no_context}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 22 | return $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 16 | ▶ | sub decompress { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decompress: called CC=12 SCAR=27.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 16 | my ($self, $payload) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 16 | ▶ | croak 'decompress(): payload must be a defined scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $payload or ref $payload
MC/DC0%0/2
not defined $payload or ref $payload
not defined $payload
ref $payload
Truth table33%1/3
not(A) or B
A= not defined $payloadB= ref $payload
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | if !defined($payload) || ref($payload); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 16 | my $input = "$payload"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | ▶ | croak 'decompress(): payload must be a byte string' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | unless utf8::downgrade($input, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 16 | $input .= $TAIL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | ▶ | my $z = $self->{inflater} ||= $self->_new_inflater; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"inflater"} ||= $self->_new_inflater
MC/DC0%0/2
$self->{"inflater"} ||= $self->_new_inflater
$self->{"inflater"}
$self->_new_inflater
Truth table66%2/3
A ||= B
A= $self->{"inflater"}B= $self->_new_inflater
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 16 | my $output = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 16 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 16 | my $chunk = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 16 | my $before = length($input); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | my $status = $z->inflate($input, $chunk); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | ▶ | croak "permessage-deflate decompression failed: $status" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$status == Z_OK() or $status == Z_BUF_ERROR()
MC/DC50%1/2
$status == Z_OK() or $status == Z_BUF_ERROR()
$status == Z_OK()
$status == Z_BUF_ERROR()
Truth table66%2/3
A or B
A= $status == Z_OK()B= $status == Z_BUF_ERROR()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | unless $status == Z_OK || $status == Z_BUF_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 15 | $output .= $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | croak 'WebSocket message exceeds configured limit' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 15 | ▶ | if length($output) > $self->{max_message_size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 13 | ▶ | last unless length $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | croak 'permessage-deflate decompressor made no progress' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $input == $before and not length $chunk
MC/DC0%0/2
length $input == $before and not length $chunk
length $input == $before
not length $chunk
Truth table0%0/3
A and not(B)
A= length $input == $beforeB= not length $chunk
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | if length($input) == $before && !length($chunk); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 13 | ▶ | $self->{inflater} = undef if $self->{in_no_context}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 13 | return $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | return { %{ $self->{config} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||