line |
true |
false |
branch |
12
|
0 |
76185 |
assert(_state != State::DONE); |
20
|
1030 |
75155 |
if (_state == State::HEADER) { |
21
|
1030 |
0 |
if (!_header.parse(buf)) return false; |
|
565 |
465 |
if (!_header.parse(buf)) return false; |
23
|
465 |
0 |
if (opcode() > Opcode::PONG || (opcode() > Opcode::BINARY && opcode() < Opcode::CLOSE)) return _err(errc::invalid_opcode); |
|
93 |
372 |
if (opcode() > Opcode::PONG || (opcode() > Opcode::BINARY && opcode() < Opcode::CLOSE)) return _err(errc::invalid_opcode); |
|
10 |
83 |
if (opcode() > Opcode::PONG || (opcode() > Opcode::BINARY && opcode() < Opcode::CLOSE)) return _err(errc::invalid_opcode); |
|
10 |
455 |
if (opcode() > Opcode::PONG || (opcode() > Opcode::BINARY && opcode() < Opcode::CLOSE)) return _err(errc::invalid_opcode); |
|
10 |
0 |
if (opcode() > Opcode::PONG || (opcode() > Opcode::BINARY && opcode() < Opcode::CLOSE)) return _err(errc::invalid_opcode); |
25
|
455 |
0 |
if (is_control()) { |
|
83 |
372 |
if (is_control()) { |
26
|
12 |
71 |
if (!final()) return _err(errc::control_fragmented); |
|
12 |
0 |
if (!final()) return _err(errc::control_fragmented); |
27
|
12 |
59 |
if (_header.length > MAX_CONTROL_PAYLOAD) return _err(errc::control_payload_too_big); |
|
12 |
0 |
if (_header.length > MAX_CONTROL_PAYLOAD) return _err(errc::control_payload_too_big); |
28
|
1 |
58 |
if (_header.rsv1) return _err(errc::control_frame_compression); |
|
1 |
0 |
if (_header.rsv1) return _err(errc::control_frame_compression); |
31
|
62 |
368 |
if (!_header.has_mask && _mask_required && _header.length) return _err(errc::not_masked); |
|
6 |
56 |
if (!_header.has_mask && _mask_required && _header.length) return _err(errc::not_masked); |
|
4 |
2 |
if (!_header.has_mask && _mask_required && _header.length) return _err(errc::not_masked); |
|
4 |
0 |
if (!_header.has_mask && _mask_required && _header.length) return _err(errc::not_masked); |
32
|
8 |
418 |
if (_max_size && _header.length > _max_size) return _err(errc::max_frame_size); |
|
2 |
6 |
if (_max_size && _header.length > _max_size) return _err(errc::max_frame_size); |
|
2 |
0 |
if (_max_size && _header.length > _max_size) return _err(errc::max_frame_size); |
34
|
394 |
30 |
_state = _header.length ? State::PAYLOAD : State::DONE; |
38
|
75549 |
30 |
if (_state == State::PAYLOAD) { |
39
|
82 |
75467 |
if (!buf) return false; |
42
|
394 |
75073 |
if (buflen >= _payload_bytes_left) { // last needed buffer |
43
|
341 |
53 |
if (_header.has_mask) crypt_mask(buf.shared_buf(), _payload_bytes_left, _header.mask, _header.length - _payload_bytes_left); |
|
341 |
0 |
if (_header.has_mask) crypt_mask(buf.shared_buf(), _payload_bytes_left, _header.mask, _header.length - _payload_bytes_left); |
|
341 |
0 |
if (_header.has_mask) crypt_mask(buf.shared_buf(), _payload_bytes_left, _header.mask, _header.length - _payload_bytes_left); |
44
|
288 |
106 |
if (buflen == _payload_bytes_left) { // payload is the whole buf |
45
|
288 |
0 |
payload.push_back(buf); |
49
|
106 |
0 |
payload.push_back(buf.substr(0, _payload_bytes_left)); |
|
106 |
0 |
payload.push_back(buf.substr(0, _payload_bytes_left)); |
50
|
106 |
0 |
buf.offset(_payload_bytes_left); // leave the rest in buf |
55
|
75067 |
6 |
if (_header.has_mask) crypt_mask(buf.shared_buf(), buflen, _header.mask, _header.length - _payload_bytes_left); |
|
75067 |
0 |
if (_header.has_mask) crypt_mask(buf.shared_buf(), buflen, _header.mask, _header.length - _payload_bytes_left); |
|
75067 |
0 |
if (_header.has_mask) crypt_mask(buf.shared_buf(), buflen, _header.mask, _header.length - _payload_bytes_left); |
57
|
75073 |
0 |
payload.push_back(buf); |
62
|
35 |
389 |
if (opcode() == Opcode::CLOSE) { |
64
|
4 |
31 |
if (!_header.length) _close_code = (uint16_t)CloseCode::UNKNOWN; |
67
|
20 |
11 |
if (payload.size() == 1) str = payload[0]; |
|
20 |
0 |
if (payload.size() == 1) str = payload[0]; |
69
|
11 |
0 |
str.reserve(_header.length); |
70
|
36 |
11 |
for (const auto& s : payload) str += s; |
|
36 |
0 |
for (const auto& s : payload) str += s; |
73
|
31 |
0 |
if (!FrameHeader::parse_close_payload(str, _close_code, _close_message)) return _err(errc::close_frame_invalid_data); |
|
18 |
13 |
if (!FrameHeader::parse_close_payload(str, _close_code, _close_message)) return _err(errc::close_frame_invalid_data); |
|
18 |
0 |
if (!FrameHeader::parse_close_payload(str, _close_code, _close_message)) return _err(errc::close_frame_invalid_data); |
76
|
13 |
0 |
payload.push_back(_close_message); |
77
|
13 |
18 |
_header.length = _close_message.length(); |
85
|
18 |
0 |
}}} |
|
18 |
0 |
}}} |