Branch Coverage

src/panda/protocol/websocket/ConnectRequest.cc
Criterion Covered Total %
branch 87 144 60.4


line true false branch
12 1 240 if (_method != Method::GET) {
17 0 240 if (http_version != 11) {
22 240 0 if (!body.empty()) {
0 240 if (!body.empty()) {
27 240 0 auto it = headers.find("Connection");
28 240 0 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
240 0 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
0 240 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
240 0 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
240 0 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
0 240 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
0 0 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
0 0 if (it == headers.end() || !string_contains_ci(it->value, "upgrade")) {
33 240 0 it = headers.find("Upgrade");
34 240 0 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
240 0 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
2 238 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
240 0 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
240 0 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
2 238 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
0 0 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
0 0 if (it == headers.end() || !string_contains_ci(it->value, "websocket")) {
40 238 0 it = headers.find("Sec-WebSocket-Key");
41 238 0 if (it != headers.end()) {
42 238 0 ws_key = it->value;
43 238 0 auto decoded = panda::encode::decode_base64(ws_key);
44 238 0 if (decoded.length() == 16) ok = true;
46 0 238 if (!ok) {
52 238 0 it = headers.find("Sec-WebSocket-Version");
53 238 0 if (it != headers.end()) {
54 238 0 it->value.to_number(ws_version);
55 238 3 for (int v : supported_ws_versions) {
56 3 235 if (ws_version != v) continue;
61 3 235 if (!_ws_version_supported) {
66 235 0 auto ext_range = headers.get_multi("Sec-WebSocket-Extensions");
67 235 0 for (auto& val : ext_range) {
235 0 for (auto& val : ext_range) {
324 0 for (auto& val : ext_range) {
89 235 for (auto& val : ext_range) {
89 0 for (auto& val : ext_range) {
89 0 for (auto& val : ext_range) {
68 89 0 parse_header_value(val, _ws_extensions);
71 235 0 ws_protocol = headers.get("Sec-WebSocket-Protocol");
235 0 ws_protocol = headers.get("Sec-WebSocket-Protocol");
79 105 0 if (!uri || !uri->host()) {
1 104 if (!uri || !uri->host()) {
1 104 if (!uri || !uri->host()) {
82 104 0 if (uri && uri->scheme() && uri->scheme() != "ws" && uri->scheme() != "wss") {
104 0 if (uri && uri->scheme() && uri->scheme() != "ws" && uri->scheme() != "wss") {
4 100 if (uri && uri->scheme() && uri->scheme() != "ws" && uri->scheme() != "wss") {
1 3 if (uri && uri->scheme() && uri->scheme() != "ws" && uri->scheme() != "wss") {
1 103 if (uri && uri->scheme() && uri->scheme() != "ws" && uri->scheme() != "wss") {
85 1 102 if (body.length()) {
91 23 79 if (!ws_key) {
93 23 0 ws_key = panda::encode::encode_base64(string_view((const char*)keybuf, sizeof(keybuf)), false, true);
23 0 ws_key = panda::encode::encode_base64(string_view((const char*)keybuf, sizeof(keybuf)), false, true);
95 102 0 headers.set("Sec-WebSocket-Key", ws_key);
97 25 77 if (ws_protocol) headers.set("Sec-WebSocket-Protocol", ws_protocol);
25 0 if (ws_protocol) headers.set("Sec-WebSocket-Protocol", ws_protocol);
99 76 26 if (!ws_version) ws_version = 13;
100 102 0 headers.set("Sec-WebSocket-Version", string::from_number(ws_version));
102 88 14 if (_ws_extensions.size()) headers.set("Sec-WebSocket-Extensions", compile_header_value(_ws_extensions));
88 0 if (_ws_extensions.size()) headers.set("Sec-WebSocket-Extensions", compile_header_value(_ws_extensions));
104 102 0 headers.set("Connection", "Upgrade");
105 102 0 headers.set("Upgrade", "websocket");
107 102 0 if (!headers.has("User-Agent")) headers.add("User-Agent", "Panda-WebSocket");
100 2 if (!headers.has("User-Agent")) headers.add("User-Agent", "Panda-WebSocket");
100 0 if (!headers.has("User-Agent")) headers.add("User-Agent", "Panda-WebSocket");
108 102 0 if (!headers.has("Host")) headers.add("Host", uri->host());
101 1 if (!headers.has("Host")) headers.add("Host", uri->host());
101 0 if (!headers.has("Host")) headers.add("Host", uri->host());
114 90 0 return new ConnectResponse();