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