line |
true |
false |
branch |
21
|
18 |
0 |
panda::string loaded_version{zlibVersion()}; |
23
|
18 |
0 |
if (compiled_verison != loaded_version) { |
|
0 |
18 |
if (compiled_verison != loaded_version) { |
24
|
0 |
0 |
panda::string err = "zlib version mismatch, loaded: " + loaded_version + ", compiled" + compiled_verison; |
|
0 |
0 |
panda::string err = "zlib version mismatch, loaded: " + loaded_version + ", compiled" + compiled_verison; |
|
0 |
0 |
panda::string err = "zlib version mismatch, loaded: " + loaded_version + ", compiled" + compiled_verison; |
25
|
0 |
0 |
return result_t{err}; |
33
|
88 |
0 |
}); |
34
|
3 |
85 |
if (iter != ws_extensions.end()) { |
39
|
85 |
0 |
params.emplace(PARAM_SERVER_MAX_WINDOW_BITS, panda::to_string(cfg.server_max_window_bits)); |
|
85 |
0 |
params.emplace(PARAM_SERVER_MAX_WINDOW_BITS, panda::to_string(cfg.server_max_window_bits)); |
40
|
85 |
0 |
params.emplace(PARAM_CLIENT_MAX_WINDOW_BITS, panda::to_string(cfg.client_max_window_bits)); |
|
85 |
0 |
params.emplace(PARAM_CLIENT_MAX_WINDOW_BITS, panda::to_string(cfg.client_max_window_bits)); |
41
|
3 |
82 |
if(cfg.server_no_context_takeover) params.emplace(PARAM_SERVER_NO_CONTEXT_TAKEOVER, ""); |
|
3 |
0 |
if(cfg.server_no_context_takeover) params.emplace(PARAM_SERVER_NO_CONTEXT_TAKEOVER, ""); |
42
|
3 |
82 |
if(cfg.client_no_context_takeover) params.emplace(PARAM_CLIENT_NO_CONTEXT_TAKEOVER, ""); |
|
3 |
0 |
if(cfg.client_no_context_takeover) params.emplace(PARAM_CLIENT_NO_CONTEXT_TAKEOVER, ""); |
45
|
85 |
0 |
HeaderValue hv {name, std::move(params)}; |
46
|
85 |
0 |
ws_extensions.emplace_back(std::move(hv)); |
51
|
263 |
0 |
auto res = from_chars(value.data(), value.data() + value.size(), bits, 10); |
52
|
261 |
2 |
return !res.ec && (bits >= 9) && (bits <= 15); |
|
257 |
4 |
return !res.ec && (bits >= 9) && (bits <= 15); |
|
256 |
1 |
return !res.ec && (bits >= 9) && (bits <= 15); |
56
|
155 |
12 |
for(auto& header: values) { |
57
|
155 |
0 |
if (header.name == extension_name) { |
|
151 |
4 |
if (header.name == extension_name) { |
60
|
420 |
10 |
for(auto it = begin(header.params); params_correct && it != end(header.params); ++it) { |
|
279 |
141 |
for(auto it = begin(header.params); params_correct && it != end(header.params); ++it) { |
|
420 |
10 |
for(auto it = begin(header.params); params_correct && it != end(header.params); ++it) { |
|
279 |
151 |
for(auto it = begin(header.params); params_correct && it != end(header.params); ++it) { |
63
|
279 |
0 |
if (param_name == PARAM_SERVER_NO_CONTEXT_TAKEOVER) { |
|
5 |
274 |
if (param_name == PARAM_SERVER_NO_CONTEXT_TAKEOVER) { |
67
|
274 |
0 |
else if (param_name == PARAM_CLIENT_NO_CONTEXT_TAKEOVER) { |
|
5 |
269 |
else if (param_name == PARAM_CLIENT_NO_CONTEXT_TAKEOVER) { |
71
|
269 |
0 |
else if (param_name == PARAM_SERVER_MAX_WINDOW_BITS) { |
|
131 |
138 |
else if (param_name == PARAM_SERVER_MAX_WINDOW_BITS) { |
74
|
131 |
0 |
params_correct = get_window_bits(param_value, bits); |
75
|
129 |
2 |
if (params_correct) { |
77
|
61 |
68 |
if (role == Role::CLIENT) { |
84
|
138 |
0 |
else if (param_name == PARAM_CLIENT_MAX_WINDOW_BITS) { |
|
136 |
2 |
else if (param_name == PARAM_CLIENT_MAX_WINDOW_BITS) { |
88
|
132 |
4 |
if (param_value) { |
89
|
132 |
0 |
params_correct = get_window_bits(param_value, bits); |
91
|
127 |
5 |
params_correct = params_correct && ( |
|
64 |
63 |
params_correct = params_correct && ( |
|
64 |
0 |
params_correct = params_correct && ( |
|
63 |
0 |
params_correct = params_correct && ( |
102
|
141 |
10 |
if (params_correct) { |
107
|
4 |
6 |
else if (role == Role::CLIENT) { |
119
|
5 |
136 |
if (ecfg.flags & EffectiveConfig::HAS_SERVER_NO_CONTEXT_TAKEOVER) { |
120
|
5 |
0 |
params.emplace(PARAM_SERVER_NO_CONTEXT_TAKEOVER, ""); |
122
|
5 |
136 |
if (ecfg.flags & EffectiveConfig::HAS_CLIENT_NO_CONTEXT_TAKEOVER) { |
123
|
5 |
0 |
params.emplace(PARAM_CLIENT_NO_CONTEXT_TAKEOVER, ""); |
125
|
124 |
17 |
if (ecfg.flags & EffectiveConfig::HAS_SERVER_MAX_WINDOW_BITS) { |
126
|
124 |
0 |
params.emplace(PARAM_SERVER_MAX_WINDOW_BITS, to_string(ecfg.cfg.server_max_window_bits)); |
|
124 |
0 |
params.emplace(PARAM_SERVER_MAX_WINDOW_BITS, to_string(ecfg.cfg.server_max_window_bits)); |
128
|
128 |
13 |
if (ecfg.flags & EffectiveConfig::HAS_CLIENT_MAX_WINDOW_BITS) { |
129
|
128 |
0 |
params.emplace(PARAM_CLIENT_MAX_WINDOW_BITS, to_string(ecfg.cfg.client_max_window_bits)); |
|
128 |
0 |
params.emplace(PARAM_CLIENT_MAX_WINDOW_BITS, to_string(ecfg.cfg.client_max_window_bits)); |
131
|
141 |
0 |
extensions.emplace_back(HeaderValue{string(extension_name), params}); |
|
141 |
0 |
extensions.emplace_back(HeaderValue{string(extension_name), params}); |
132
|
141 |
0 |
return new DeflateExt(ecfg.cfg, role); |
|
141 |
0 |
return new DeflateExt(ecfg.cfg, role); |
137
|
61 |
80 |
auto rx_window = role == Role::CLIENT ? cfg.server_max_window_bits : cfg.client_max_window_bits; |
138
|
61 |
80 |
auto tx_window = role == Role::CLIENT ? cfg.client_max_window_bits : cfg.server_max_window_bits; |
148
|
0 |
141 |
if (r != Z_OK) { |
150
|
0 |
0 |
if (rx_stream.msg) err.append(panda::string(" : ") + rx_stream.msg); |
|
0 |
0 |
if (rx_stream.msg) err.append(panda::string(" : ") + rx_stream.msg); |
|
0 |
0 |
if (rx_stream.msg) err.append(panda::string(" : ") + rx_stream.msg); |
162
|
0 |
141 |
if (r != Z_OK) { |
164
|
0 |
0 |
if (rx_stream.msg) err.append(panda::string(" : ") + rx_stream.msg); |
|
0 |
0 |
if (rx_stream.msg) err.append(panda::string(" : ") + rx_stream.msg); |
|
0 |
0 |
if (rx_stream.msg) err.append(panda::string(" : ") + rx_stream.msg); |
169
|
59 |
2 |
(role == Role::CLIENT && cfg.client_no_context_takeover) |
170
|
61 |
80 |
|| (role == Role::SERVER && cfg.server_no_context_takeover); |
|
80 |
59 |
|| (role == Role::SERVER && cfg.server_no_context_takeover); |
|
3 |
77 |
|| (role == Role::SERVER && cfg.server_no_context_takeover); |
172
|
59 |
2 |
(role == Role::CLIENT && cfg.server_no_context_takeover) |
173
|
61 |
80 |
|| (role == Role::SERVER && cfg.client_no_context_takeover); |
|
80 |
59 |
|| (role == Role::SERVER && cfg.client_no_context_takeover); |
|
5 |
75 |
|| (role == Role::SERVER && cfg.client_no_context_takeover); |
177
|
2 |
6 |
if (!tx_stream.next_in) return; |
180
|
0 |
6 |
if (deflateReset(&tx_stream) != Z_OK) { |
182
|
0 |
0 |
if (tx_stream.msg) { |
183
|
0 |
0 |
err += tx_stream.msg; |
190
|
0 |
15 |
if (!rx_stream.next_in) return; |
193
|
0 |
15 |
if (inflateReset(&rx_stream) != Z_OK) { |
195
|
0 |
0 |
if(rx_stream.msg) { |
196
|
0 |
0 |
err += rx_stream.msg; |
203
|
141 |
0 |
if (deflateEnd(&tx_stream) != Z_OK) { |
205
|
0 |
141 |
if (tx_stream.msg) { |
208
|
0 |
141 |
assert(err.c_str()); |
210
|
0 |
141 |
if (inflateEnd(&rx_stream) != Z_OK) { |
212
|
0 |
0 |
if(rx_stream.msg) { |
215
|
0 |
0 |
assert(err.c_str()); |
221
|
22 |
0 |
string in = str; |
224
|
22 |
0 |
str = string(in.length() * COMPRESS_PREALLOCATE_RATIO); // detach and realloc for result here |
|
22 |
0 |
str = string(in.length() * COMPRESS_PREALLOCATE_RATIO); // detach and realloc for result here |
225
|
22 |
0 |
tx_stream.next_out = reinterpret_cast(str.buf()); // buf would not detach, we just created new string and refcnt == 1 |
226
|
22 |
0 |
auto sz = str.capacity(); |
232
|
22 |
0 |
}); |
236
|
16 |
6 |
if (final) { |
238
|
0 |
16 |
if (reset_after_tx) reset_tx(); |
|
0 |
0 |
if (reset_after_tx) reset_tx(); |
247
|
3 |
47 |
if (frame.payload_length() == 0) r = true; |
251
|
46 |
4 |
if(!r || (frame.final() && reset_after_rx)) reset_rx(); |
|
32 |
14 |
if(!r || (frame.final() && reset_after_rx)) reset_rx(); |
|
11 |
21 |
if(!r || (frame.final() && reset_after_rx)) reset_rx(); |
|
15 |
35 |
if(!r || (frame.final() && reset_after_rx)) reset_rx(); |
252
|
34 |
16 |
if (frame.final()) message_size = 0; |
259
|
2 |
7 |
if (unpacked_message_size > max_message_size) { |
284
|
47 |
0 |
acc.reserve(frame.payload_length() * UNCOMPRESS_PREALLOCATE_RATIO); |
286
|
47 |
0 |
rx_stream.next_out = reinterpret_cast(acc.buf()); |
287
|
47 |
0 |
rx_stream.avail_out = static_cast(acc.capacity()); |
289
|
0 |
43 |
do { |
292
|
47 |
0 |
if (it_next == end && final) { |
|
31 |
16 |
if (it_next == end && final) { |
|
31 |
16 |
if (it_next == end && final) { |
295
|
31 |
0 |
chunk_in.append(reinterpret_cast(trailer), TRAILER_SIZE); |
299
|
47 |
0 |
rx_stream.next_in = reinterpret_cast(chunk_in.buf()); |
301
|
47 |
0 |
auto flush = (it_next == end) ? Z_SYNC_FLUSH : Z_NO_FLUSH; |
303
|
86 |
43 |
do { |
305
|
133 |
0 |
auto r = inflate(&rx_stream, flush); |
308
|
9 |
122 |
if (max_message_size && !uncompress_check_overflow(frame, acc)) return false; |
|
9 |
0 |
if (max_message_size && !uncompress_check_overflow(frame, acc)) return false; |
|
2 |
7 |
if (max_message_size && !uncompress_check_overflow(frame, acc)) return false; |
|
2 |
129 |
if (max_message_size && !uncompress_check_overflow(frame, acc)) return false; |
309
|
86 |
43 |
if (!rx_stream.avail_out) { |
310
|
86 |
0 |
rx_increase_buffer(acc); |
326
|
2 |
0 |
if (rx_stream.msg) err += rx_stream.msg; |
|
2 |
0 |
if (rx_stream.msg) err += rx_stream.msg; |
327
|
0 |
0 |
else err += to_string(r); |
|
0 |
0 |
else err += to_string(r); |
328
|
0 |
2 |
panda_log_info(err); |
|
0 |
0 |
panda_log_info(err); |
|
0 |
2 |
panda_log_info(err); |
|
0 |
0 |
panda_log_info(err); |
|
0 |
0 |
panda_log_info(err); |
|
0 |
0 |
panda_log_info(err); |
336
|
43 |
0 |
acc.length(acc.capacity() - rx_stream.avail_out); |
339
|
39 |
4 |
if (acc) { |
340
|
39 |
0 |
frame.payload.resize(1); |
341
|
39 |
0 |
frame.payload[0] = std::move(acc); |