line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::Base::DataFrame; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
7059
|
use strict; |
|
15
|
|
|
|
|
36
|
|
|
15
|
|
|
|
|
437
|
|
4
|
15
|
|
|
15
|
|
89
|
use warnings; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
437
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
|
|
86
|
use parent qw( |
7
|
|
|
|
|
|
|
Net::WebSocket::Frame |
8
|
15
|
|
|
15
|
|
79
|
); |
|
15
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant { |
11
|
15
|
|
|
|
|
1511
|
is_control => 0, |
12
|
|
|
|
|
|
|
_MAX_32_BIT_LENGTH => 0xffffffff, |
13
|
15
|
|
|
15
|
|
884
|
}; |
|
15
|
|
|
|
|
41
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#accessed from tests |
16
|
|
|
|
|
|
|
our $_can_pack_Q; |
17
|
|
|
|
|
|
|
BEGIN { |
18
|
15
|
|
|
15
|
|
51
|
$_can_pack_Q = eval { pack 'Q', 0 }; |
|
15
|
|
|
|
|
4905
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $length; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _assemble_length { |
24
|
77
|
|
|
77
|
|
160
|
my ($class, $payload_sr) = @_; |
25
|
|
|
|
|
|
|
|
26
|
77
|
|
|
|
|
115
|
my ($byte2, $len_len); |
27
|
|
|
|
|
|
|
|
28
|
77
|
|
|
|
|
134
|
$length = length $$payload_sr; |
29
|
|
|
|
|
|
|
|
30
|
77
|
100
|
|
|
|
170
|
if ($length < 126) { |
|
|
100
|
|
|
|
|
|
31
|
70
|
|
|
|
|
155
|
$byte2 = chr(length $$payload_sr); |
32
|
70
|
|
|
|
|
110
|
$len_len = q<>; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ($length < 65536) { |
35
|
5
|
|
|
|
|
11
|
$byte2 = "\x7e"; #126 |
36
|
5
|
|
|
|
|
24
|
$len_len = pack 'n', $length; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
2
|
|
|
|
|
5
|
$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
|
|
|
|
|
11
|
$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
|
|
|
|
|
241
|
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
|
29
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
13
|
|
100
|
|
|
22
|
return( ord ("\x80" & ${$self->[$self->FIRST2]}) && 1 ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |