| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
MODULE = Protocol::WebSocket::Fast PACKAGE = Protocol::WebSocket::Fast::Parser |
|
2
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
3
|
|
|
|
|
|
|
|
|
4
|
31
|
50
|
|
|
|
|
void Parser::configure (Parser::Config config) |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
|
size_t Parser::max_frame_size () |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
|
|
|
size_t Parser::max_message_size () |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
|
size_t Parser::max_handshake_size () |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Scalar Parser::deflate_config () { |
|
13
|
204
|
50
|
|
|
|
|
auto deflate_cfg = THIS->deflate_config(); |
|
|
|
100
|
|
|
|
|
|
|
14
|
102
|
100
|
|
|
|
|
if (deflate_cfg) { |
|
15
|
98
|
50
|
|
|
|
|
RETVAL = xs::out(deflate_cfg.value()); |
|
|
|
50
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
} |
|
17
|
4
|
|
|
|
|
|
else XSRETURN_UNDEF; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Scalar Parser::effective_deflate_config () { |
|
21
|
8
|
50
|
|
|
|
|
auto deflate_cfg = THIS->effective_deflate_config(); |
|
|
|
50
|
|
|
|
|
|
|
22
|
4
|
50
|
|
|
|
|
if (deflate_cfg) { |
|
23
|
4
|
50
|
|
|
|
|
RETVAL = xs::out(deflate_cfg.value()); |
|
|
|
50
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} |
|
25
|
0
|
|
|
|
|
|
else XSRETURN_UNDEF; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
325
|
|
|
|
|
|
bool Parser::established () |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
bool Parser::recv_closed () |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
bool Parser::send_closed () |
|
33
|
|
|
|
|
|
|
|
|
34
|
93
|
|
|
|
|
|
bool Parser::is_deflate_active () |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
void Parser::get_frames (string buf = string()) { |
|
37
|
144794
|
50
|
|
|
|
|
auto frames = buf ? THIS->get_frames(buf) : THIS->get_frames(); |
|
|
|
100
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
38
|
72458
|
50
|
|
|
|
|
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); |
|
|
|
0
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
else { |
|
40
|
72337
|
50
|
|
|
|
|
if (frames.begin() == frames.end()) XSRETURN_UNDEF; |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
41
|
92
|
50
|
|
|
|
|
auto itsv = xs::out(new XSFrameIterator(frames.begin())); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
42
|
46
|
50
|
|
|
|
|
mPUSHs(itsv.detach()); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
void Parser::get_messages (string buf = string()) { |
|
47
|
7323
|
100
|
|
|
|
|
auto messages = buf ? THIS->get_messages(buf) : THIS->get_messages(); |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
48
|
3815
|
50
|
|
|
|
|
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); |
|
|
|
0
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
else { |
|
50
|
3515
|
50
|
|
|
|
|
if (messages.begin() == messages.end()) XSRETURN_UNDEF; |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
51
|
64
|
50
|
|
|
|
|
auto itsv = xs::out(new XSMessageIterator(messages.begin())); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
52
|
32
|
50
|
|
|
|
|
mPUSHs(itsv.detach()); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
XSFrameSender* Parser::start_message (...) { |
|
57
|
100
|
|
|
|
|
|
Opcode opcode = Opcode::BINARY; |
|
58
|
50
|
|
|
|
|
|
auto deflate = DeflateFlag::NO; |
|
59
|
50
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
for (I32 i = 1; i < items - 1; i += 2) { |
|
61
|
98
|
100
|
|
|
|
|
auto name = xs::in(ST(i)); |
|
62
|
48
|
50
|
|
|
|
|
if (!name.length()) continue; |
|
63
|
48
|
50
|
|
|
|
|
auto val = ST(i+1); |
|
64
|
48
|
|
|
|
|
|
switch (name[0]) { |
|
65
|
48
|
|
|
|
|
|
case 'd': if (name == "deflate") deflate = SvTRUE(val) ? DeflateFlag::YES : DeflateFlag::NO; break; |
|
66
|
32
|
50
|
|
|
|
|
case 'o': if (name == "opcode") opcode = (Opcode)SvIV(val); break; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
67
|
48
|
50
|
|
|
|
|
} |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
RETVAL = new XSFrameSender(THIS->start_message(opcode, deflate)); |
|
71
|
50
|
100
|
|
|
|
|
} |
|
|
|
50
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Simple Parser::send_control (int opcode, string payload = string()) { |
|
74
|
36
|
50
|
|
|
|
|
auto range = THIS->send_control((Opcode)opcode, payload); |
|
|
|
50
|
|
|
|
|
|
|
75
|
18
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Simple Parser::send_ping (string payload = string()) { |
|
79
|
12
|
50
|
|
|
|
|
auto range = THIS->send_ping(payload); |
|
|
|
50
|
|
|
|
|
|
|
80
|
6
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Simple Parser::send_pong (string payload = string()) { |
|
84
|
10
|
50
|
|
|
|
|
auto range = THIS->send_pong(payload); |
|
|
|
50
|
|
|
|
|
|
|
85
|
5
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Simple Parser::send_close (SV* code = NULL, string message = string()) { |
|
89
|
4
|
100
|
|
|
|
|
if (code) { |
|
90
|
6
|
50
|
|
|
|
|
auto range = THIS->send_close((uint16_t)SvUV(code), message); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
91
|
3
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
1
|
50
|
|
|
|
|
else RETVAL = xs::out(THIS->send_close()); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Simple Parser::send_message (...) : ALIAS(send_message_multiframe=1) { |
|
97
|
111
|
|
|
|
|
|
auto builder = THIS->message(); |
|
98
|
|
|
|
|
|
|
|
|
99
|
222
|
50
|
|
|
|
|
Sv payload_sv; |
|
100
|
232
|
100
|
|
|
|
|
for (I32 i = 1; i < items - 1; i += 2) { |
|
101
|
121
|
50
|
|
|
|
|
auto name = xs::in(ST(i)); |
|
102
|
121
|
50
|
|
|
|
|
if (!name.length()) continue; |
|
103
|
121
|
|
|
|
|
|
auto val = ST(i+1); |
|
104
|
121
|
|
|
|
|
|
switch (name[0]) { |
|
105
|
6
|
50
|
|
|
|
|
case 'd': if (name == "deflate" && SvOK(val)) builder.deflate(SvTRUE(val)); break; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
106
|
4
|
50
|
|
|
|
|
case 'o': if (name == "opcode") builder.opcode((Opcode)SvIV(val)); break; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
107
|
121
|
50
|
|
|
|
|
case 'p': if (name == "payload") payload_sv = val; break; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
111
|
100
|
|
|
|
|
if (ix == 0) { // send_message() |
|
112
|
107
|
50
|
|
|
|
|
if (payload_sv.is_array_ref()) { |
|
|
|
100
|
|
|
|
|
|
|
113
|
2
|
50
|
|
|
|
|
Array payload(payload_sv); |
|
114
|
2
|
|
|
|
|
|
std::vector list; |
|
115
|
1
|
50
|
|
|
|
|
av_to_vstring(payload, list); |
|
116
|
2
|
50
|
|
|
|
|
auto range = builder.send(list.begin(), list.end()); |
|
117
|
1
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
else { |
|
120
|
213
|
50
|
|
|
|
|
auto payload = Simple(payload_sv).as_string(); |
|
|
|
50
|
|
|
|
|
|
|
121
|
212
|
50
|
|
|
|
|
auto range = builder.send(payload); |
|
122
|
106
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
else { // send_message_multiframe() |
|
126
|
8
|
50
|
|
|
|
|
Array payloads(payload_sv); |
|
127
|
4
|
50
|
|
|
|
|
if (!payloads) throw Error("invalid argument (payload must point to array)"); |
|
128
|
|
|
|
|
|
|
|
|
129
|
8
|
|
|
|
|
|
std::vector> cont; |
|
130
|
16
|
50
|
|
|
|
|
for (const auto& payload : payloads) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
131
|
12
|
50
|
|
|
|
|
if (!payload.defined()) continue; |
|
132
|
24
|
50
|
|
|
|
|
std::vector tmp; |
|
133
|
12
|
50
|
|
|
|
|
tmp.push_back(xs::in(payload)); |
|
|
|
50
|
|
|
|
|
|
|
134
|
12
|
50
|
|
|
|
|
cont.push_back(std::move(tmp)); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
8
|
50
|
|
|
|
|
auto range = builder.send(cont.begin(), cont.end()); |
|
138
|
4
|
50
|
|
|
|
|
RETVAL = strings_to_sv(range); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
132
|
|
|
|
|
|
void Parser::reset () |
|
143
|
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
|
uint16_t Parser::suggested_close_code () |
|
145
|
|
|
|
|
|
|
|
|
146
|
20
|
|
|
|
|
|
void Parser::no_deflate () |
|
147
|
|
|
|
|
|
|
|