line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::Base::DataFrame; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
7140
|
use strict; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
429
|
|
4
|
15
|
|
|
15
|
|
75
|
use warnings; |
|
15
|
|
|
|
|
44
|
|
|
15
|
|
|
|
|
426
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
|
|
99
|
use parent qw( |
7
|
|
|
|
|
|
|
Net::WebSocket::Frame |
8
|
15
|
|
|
15
|
|
73
|
); |
|
15
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant { |
11
|
15
|
|
|
|
|
1517
|
is_control => 0, |
12
|
|
|
|
|
|
|
_MAX_32_BIT_LENGTH => 0xffffffff, |
13
|
15
|
|
|
15
|
|
843
|
}; |
|
15
|
|
|
|
|
29
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#accessed from tests |
16
|
|
|
|
|
|
|
our $_can_pack_Q; |
17
|
|
|
|
|
|
|
BEGIN { |
18
|
15
|
|
|
15
|
|
53
|
$_can_pack_Q = eval { pack 'Q', 0 }; |
|
15
|
|
|
|
|
4664
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $length; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _assemble_length { |
24
|
77
|
|
|
77
|
|
164
|
my ($class, $payload_sr) = @_; |
25
|
|
|
|
|
|
|
|
26
|
77
|
|
|
|
|
118
|
my ($byte2, $len_len); |
27
|
|
|
|
|
|
|
|
28
|
77
|
|
|
|
|
138
|
$length = length $$payload_sr; |
29
|
|
|
|
|
|
|
|
30
|
77
|
100
|
|
|
|
163
|
if ($length < 126) { |
|
|
100
|
|
|
|
|
|
31
|
70
|
|
|
|
|
134
|
$byte2 = chr(length $$payload_sr); |
32
|
70
|
|
|
|
|
115
|
$len_len = q<>; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ($length < 65536) { |
35
|
5
|
|
|
|
|
10
|
$byte2 = "\x7e"; #126 |
36
|
5
|
|
|
|
|
28
|
$len_len = pack 'n', $length; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
2
|
|
|
|
|
4
|
$byte2 = "\x7f"; #127 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#Even without 64-bit support, we can still support |
42
|
|
|
|
|
|
|
#anything up to a 32-bit length |
43
|
2
|
50
|
|
|
|
8
|
if ($_can_pack_Q) { |
|
|
0
|
|
|
|
|
|
44
|
2
|
|
|
|
|
14
|
$len_len = pack 'Q>', $length; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif ($length <= _MAX_32_BIT_LENGTH) { |
47
|
0
|
|
|
|
|
0
|
$len_len = "\0\0\0\0" . (pack 'N', $length); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
0
|
|
|
|
|
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
|
|
|
|
|
254
|
return ($byte2, $len_len); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub set_fin { |
58
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
$self->_activate_highest_bit( $self->[$self->FIRST2], 0 ); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_fin { |
66
|
13
|
|
|
13
|
0
|
30
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
13
|
|
100
|
|
|
23
|
return( ord ("\x80" & ${$self->[$self->FIRST2]}) && 1 ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |