| 1 | package Net::WebSocket::Base::DataFrame; | ||||||||||||||
| 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 | |||||||||||||||
| 6 | 15 | ▶ | use parent qw( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | Net::WebSocket::Frame | ||||||||||||||
| 8 | 15 | ); | |||||||||||||
| 9 | |||||||||||||||
| 10 | 15 | ▶ | use constant { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 15 | is_control => 0, | |||||||||||||
| 12 | _MAX_32_BIT_LENGTH => 0xffffffff, | ||||||||||||||
| 13 | 15 | }; | |||||||||||||
| 14 | |||||||||||||||
| 15 | #accessed from tests | ||||||||||||||
| 16 | 15 | our $_can_pack_Q; | |||||||||||||
| 17 | 15 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | 15 | $_can_pack_Q = eval { pack 'Q', 0 }; | |||||||||||||
| 19 | } | ||||||||||||||
| 20 | |||||||||||||||
| 21 | 15 | my $length; | |||||||||||||
| 22 | |||||||||||||||
| 23 | 77 | ▶ | sub _assemble_length { | ||||||||||||
|
Subroutine
_assemble_length: called CC=5 SCAR=16.7
| |||||||||||||||
| 24 | 77 | my ($class, $payload_sr) = @_; | |||||||||||||
| 25 | |||||||||||||||
| 26 | 77 | my ($byte2, $len_len); | |||||||||||||
| 27 | |||||||||||||||
| 28 | 77 | $length = length $$payload_sr; | |||||||||||||
| 29 | |||||||||||||||
| 30 | 77 | ▶ | if ($length < 126) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 31 | 70 | $byte2 = chr(length $$payload_sr); | |||||||||||||
| 32 | 70 | $len_len = q<>; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | elsif ($length < 65536) { | ||||||||||||||
| 35 | 5 | $byte2 = "\x7e"; #126 | |||||||||||||
| 36 | 5 | $len_len = pack 'n', $length; | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | else { | ||||||||||||||
| 39 | 2 | $byte2 = "\x7f"; #127 | |||||||||||||
| 40 | |||||||||||||||
| 41 | #Even without 64-bit support, we can still support | ||||||||||||||
| 42 | #anything up to a 32-bit length | ||||||||||||||
| 43 | 2 | ▶ | if ($_can_pack_Q) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 44 | 2 | $len_len = pack 'Q>', $length; | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | elsif ($length <= _MAX_32_BIT_LENGTH) { | ||||||||||||||
| 47 | 0 | $len_len = "\0\0\0\0" . (pack 'N', $length); | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | else { | ||||||||||||||
| 50 | 0 | die sprintf( "This Perl version (%s) doesn’t support 64-bit integers, which means WebSocket frames must be no larger than %d bytes. You tried to create a %d-byte frame.", $^V, _MAX_32_BIT_LENGTH, $length); | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 77 | return ($byte2, $len_len); | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 0 | ▶ | sub set_fin { | ||||||||||||
|
Subroutine
set_fin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 58 | 0 | my ($self) = @_; | |||||||||||||
| 59 | |||||||||||||||
| 60 | 0 | $self->_activate_highest_bit( $self->[$self->FIRST2], 0 ); | |||||||||||||
| 61 | |||||||||||||||
| 62 | 0 | return $self; | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | 13 | ▶ | sub get_fin { | ||||||||||||
|
Subroutine
get_fin: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 66 | 13 | my ($self) = @_; | |||||||||||||
| 67 | |||||||||||||||
| 68 | 13 | ▶ | return( ord ("\x80" & ${$self->[$self->FIRST2]}) && 1 ); | ||||||||||||
|
Condition100%2/2
ord("\200" & ${$$self[$self->FIRST2];}) && 1
MC/DC100%1/1
ord("\200" & ${$$self[$self->FIRST2];}) && 1
ord("\200" & ${$$self[$self->FIRST2];})
Truth table100%2/2
A
A= ord("\200" & ${$$self[$self->FIRST2];})
| |||||||||||||||
| 69 | } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | 15 | 1; | |||||||||||||