line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::Constants; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
72
|
use strict; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
307
|
|
4
|
13
|
|
|
13
|
|
58
|
use warnings; |
|
13
|
|
|
|
|
40
|
|
|
13
|
|
|
|
|
561
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
|
|
943
|
use constant OPCODE => { |
7
|
|
|
|
|
|
|
continuation => 0, |
8
|
|
|
|
|
|
|
text => 1, |
9
|
|
|
|
|
|
|
binary => 2, |
10
|
|
|
|
|
|
|
close => 8, |
11
|
|
|
|
|
|
|
ping => 9, |
12
|
|
|
|
|
|
|
pong => 10, |
13
|
13
|
|
|
13
|
|
64
|
}; |
|
13
|
|
|
|
|
25
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use constant { |
16
|
13
|
|
|
|
|
1009
|
PROTOCOL_VERSION => 13, |
17
|
|
|
|
|
|
|
REQUIRED_HTTP_METHOD => 'GET', |
18
|
|
|
|
|
|
|
REQUIRED_HTTP_STATUS => 101, |
19
|
13
|
|
|
13
|
|
76
|
}; |
|
13
|
|
|
|
|
26
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#These names are taken from: |
22
|
|
|
|
|
|
|
#https://msdn.microsoft.com/en-us/library/windows/desktop/hh449350(v=vs.85).aspx |
23
|
13
|
|
|
|
|
2483
|
use constant STATUS => { |
24
|
|
|
|
|
|
|
SUCCESS => 1000, |
25
|
|
|
|
|
|
|
ENDPOINT_UNAVAILABLE => 1001, |
26
|
|
|
|
|
|
|
PROTOCOL_ERROR => 1002, |
27
|
|
|
|
|
|
|
INVALID_DATA_TYPE => 1003, |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#These are never actually sent. |
30
|
|
|
|
|
|
|
#EMPTY_CLOSE => 1005, |
31
|
|
|
|
|
|
|
#ABORTED_CLOSE => 1006, |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
INVALID_PAYLOAD => 1007, |
34
|
|
|
|
|
|
|
POLICY_VIOLATION => 1008, |
35
|
|
|
|
|
|
|
MESSAGE_TOO_BIG => 1009, |
36
|
|
|
|
|
|
|
UNSUPPORTED_EXTENSIONS => 1010, |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#Post-RFC, “server error” was changed to “internal error”. |
39
|
|
|
|
|
|
|
#We accept both names; code-to-name conversion always returns this one. |
40
|
|
|
|
|
|
|
INTERNAL_ERROR => 1011, |
41
|
|
|
|
|
|
|
SERVER_ERROR => 1011, |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#RFC says not to use this one, |
44
|
|
|
|
|
|
|
#but MS has it in their enum. |
45
|
|
|
|
|
|
|
#SECURE_HANDSHAKE_ERROR => 1015, |
46
|
13
|
|
|
13
|
|
71
|
}; |
|
13
|
|
|
|
|
24
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my %status_code_name; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub status_name_to_code { |
53
|
0
|
|
|
0
|
0
|
|
my ($name) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return STATUS()->{$name}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub status_code_to_name { |
59
|
0
|
|
|
0
|
0
|
|
my ($code) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if (!%status_code_name) { |
62
|
0
|
|
|
|
|
|
my %copy = %{ STATUS() }; |
|
0
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
delete $copy{'SERVER_ERROR'}; |
64
|
0
|
|
|
|
|
|
%status_code_name = reverse %copy; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $status_code_name{$code}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my %opcode_type; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub opcode_to_type { |
75
|
0
|
|
|
0
|
0
|
|
my ($opcode) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
%opcode_type = reverse %{ OPCODE() } if !%opcode_type; |
|
0
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $opcode_type{$opcode}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |