line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "websocket.h" |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
namespace xs { namespace protocol { namespace websocket { |
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
|
|
|
void av_to_header_values (const Array& av, HeaderValues* vals) { |
6
|
7
|
50
|
|
|
|
|
if (!av.size()) return; |
7
|
7
|
|
|
|
|
|
vals->reserve(av.size()); |
8
|
16
|
50
|
|
|
|
|
for (const auto& sv : av) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9
|
18
|
50
|
|
|
|
|
const Array subav(sv); |
10
|
9
|
50
|
|
|
|
|
if (!subav) continue; |
11
|
18
|
50
|
|
|
|
|
auto namesv = subav.fetch(0); |
|
|
50
|
|
|
|
|
|
12
|
9
|
50
|
|
|
|
|
if (!namesv) continue; |
13
|
18
|
50
|
|
|
|
|
HeaderValue elem; |
14
|
9
|
50
|
|
|
|
|
elem.name = xs::in(namesv); |
|
|
50
|
|
|
|
|
|
15
|
18
|
50
|
|
|
|
|
Hash args = subav.fetch(1); |
|
|
50
|
|
|
|
|
|
16
|
16
|
100
|
|
|
|
|
if (args) for (const auto& row : args) elem.params.emplace(string(row.key()), xs::in(row.value())); |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
17
|
9
|
50
|
|
|
|
|
vals->push_back(std::move(elem)); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
|
Array header_values_to_av (const HeaderValues& vals) { |
22
|
2
|
50
|
|
|
|
|
if (!vals.size()) return Array(); |
23
|
4
|
50
|
|
|
|
|
auto ret = Array::create(vals.size()); |
24
|
4
|
100
|
|
|
|
|
for (const auto& elem : vals) { |
25
|
4
|
50
|
|
|
|
|
auto elemav = Array::create(2); |
26
|
2
|
50
|
|
|
|
|
elemav.push(xs::out(elem.name)); |
|
|
50
|
|
|
|
|
|
27
|
2
|
50
|
|
|
|
|
if (elem.params.size()) { |
28
|
4
|
50
|
|
|
|
|
auto args = Hash::create(elem.params.size()); |
29
|
4
|
100
|
|
|
|
|
for (const auto& param : elem.params) { |
30
|
2
|
50
|
|
|
|
|
args.store(param.first, xs::out(param.second)); |
|
|
50
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
2
|
50
|
|
|
|
|
elemav.push(Ref::create(args)); |
|
|
50
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
2
|
50
|
|
|
|
|
ret.push(Ref::create(elemav)); |
|
|
50
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
2
|
|
|
|
|
|
return ret; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
23
|
|
|
|
|
|
void av_to_vstring (const Array& av, std::vector& v) { |
40
|
1197495
|
50
|
|
|
|
|
for (const auto& elem : av) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
41
|
1197472
|
50
|
|
|
|
|
if (!elem.defined()) continue; |
42
|
1197472
|
50
|
|
|
|
|
v.push_back(xs::in(elem)); |
|
|
50
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
23
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
83
|
|
|
|
|
|
ConnectRequestSP make_request (const Hash& params, const ConnectRequestSP& dest) { |
47
|
83
|
50
|
|
|
|
|
auto ret = dest ? dest : ConnectRequestSP(new ConnectRequest()); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
48
|
83
|
50
|
|
|
|
|
http::fill(ret, params); |
49
|
|
|
|
|
|
|
|
50
|
166
|
|
|
|
|
|
Scalar val; |
51
|
|
|
|
|
|
|
|
52
|
83
|
50
|
|
|
|
|
if ((val = params.fetch("ws_key"))) ret->ws_key = xs::in(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
53
|
83
|
50
|
|
|
|
|
if ((val = params.fetch("ws_version"))) ret->ws_version = SvIV(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
54
|
83
|
50
|
|
|
|
|
if ((val = params.fetch("ws_protocol"))) ret->ws_protocol = xs::in(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
83
|
50
|
|
|
|
|
if ((val = params.fetch("ws_extensions"))) { |
|
|
100
|
|
|
|
|
|
57
|
12
|
50
|
|
|
|
|
auto exts_av = xs::in(val); |
58
|
12
|
|
|
|
|
|
HeaderValues exts; |
59
|
6
|
50
|
|
|
|
|
if (exts_av) av_to_header_values(exts_av, &exts); |
|
|
50
|
|
|
|
|
|
60
|
6
|
50
|
|
|
|
|
ret->ws_extensions(exts); |
61
|
|
|
|
|
|
|
} |
62
|
166
|
|
|
|
|
|
return ret; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
|
ConnectResponseSP make_response (const Hash& params, const ConnectResponseSP& dest) { |
66
|
1
|
50
|
|
|
|
|
auto ret = dest ? dest : ConnectResponseSP(new ConnectResponse()); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
67
|
1
|
50
|
|
|
|
|
http::fill(ret, params); |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
|
Scalar val; |
70
|
|
|
|
|
|
|
|
71
|
1
|
50
|
|
|
|
|
if ((val = params.fetch("ws_extensions"))) { |
|
|
50
|
|
|
|
|
|
72
|
2
|
|
|
|
|
|
HeaderValues exts; |
73
|
1
|
50
|
|
|
|
|
av_to_header_values(xs::in(val), &exts); |
|
|
50
|
|
|
|
|
|
74
|
1
|
50
|
|
|
|
|
ret->ws_extensions(exts); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
1
|
50
|
|
|
|
|
if ((val = params.fetch("ws_protocol"))) ret->ws_protocol = xs::in(val); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
|
return ret; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
51
|
|
|
|
|
|
void parser_config_in (Parser::Config& cfg, const Hash& h) { |
83
|
102
|
|
|
|
|
|
Scalar val; |
84
|
51
|
50
|
|
|
|
|
if ((val = h.fetch("max_frame_size"))) cfg.max_frame_size = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
85
|
51
|
50
|
|
|
|
|
if ((val = h.fetch("max_message_size"))) cfg.max_message_size = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
86
|
51
|
50
|
|
|
|
|
if ((val = h.fetch("max_handshake_size"))) cfg.max_handshake_size = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
87
|
51
|
50
|
|
|
|
|
if ((val = h.fetch("check_utf8"))) cfg.check_utf8 = val.is_true(); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
51
|
50
|
|
|
|
|
if(h.exists("deflate")) cfg.deflate.reset(); |
|
|
100
|
|
|
|
|
|
90
|
102
|
50
|
|
|
|
|
Hash deflate_settings = h.fetch("deflate"); |
|
|
50
|
|
|
|
|
|
91
|
51
|
100
|
|
|
|
|
if (deflate_settings) { |
92
|
23
|
50
|
|
|
|
|
auto dcfg = xs::in(deflate_settings); |
93
|
23
|
|
|
|
|
|
cfg.deflate = dcfg; |
94
|
|
|
|
|
|
|
} |
95
|
51
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
23
|
|
|
|
|
|
void deflate_config_in (DeflateExt::Config& cfg, const Hash& h) { |
98
|
46
|
|
|
|
|
|
Scalar val; |
99
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("server_max_window_bits"))) cfg.server_max_window_bits = static_cast(Simple(val)); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
100
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("client_max_window_bits"))) cfg.client_max_window_bits = static_cast(Simple(val)); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
101
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("client_no_context_takeover"))) cfg.client_no_context_takeover = SvTRUE(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
102
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("server_no_context_takeover"))) cfg.server_no_context_takeover = SvTRUE(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
103
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("mem_level"))) cfg.mem_level = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
104
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("compression_level"))) cfg.compression_level = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
105
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("strategy"))) cfg.strategy = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
106
|
23
|
50
|
|
|
|
|
if ((val = h.fetch("compression_threshold"))) cfg.compression_threshold = Simple(val); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
107
|
23
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
102
|
|
|
|
|
|
Sv deflate_config_out (const DeflateExt::Config& cfg) { |
110
|
204
|
50
|
|
|
|
|
Hash settings = Hash::create(); |
111
|
102
|
50
|
|
|
|
|
settings.store("server_max_window_bits", Simple(cfg.server_max_window_bits)); |
|
|
50
|
|
|
|
|
|
112
|
102
|
50
|
|
|
|
|
settings.store("client_max_window_bits", Simple(cfg.client_max_window_bits)); |
|
|
50
|
|
|
|
|
|
113
|
102
|
50
|
|
|
|
|
settings.store("client_no_context_takeover", Simple(cfg.client_no_context_takeover)); |
|
|
50
|
|
|
|
|
|
114
|
102
|
50
|
|
|
|
|
settings.store("server_no_context_takeover", Simple(cfg.server_no_context_takeover)); |
|
|
50
|
|
|
|
|
|
115
|
102
|
50
|
|
|
|
|
settings.store("mem_level", Simple(cfg.mem_level)); |
|
|
50
|
|
|
|
|
|
116
|
102
|
50
|
|
|
|
|
settings.store("compression_level", Simple(cfg.compression_level)); |
|
|
50
|
|
|
|
|
|
117
|
102
|
50
|
|
|
|
|
settings.store("strategy", Simple(cfg.strategy)); |
|
|
50
|
|
|
|
|
|
118
|
102
|
50
|
|
|
|
|
settings.store("compression_threshold", Simple(cfg.compression_threshold)); |
|
|
50
|
|
|
|
|
|
119
|
204
|
50
|
|
|
|
|
return Ref::create(settings); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
}}} |