| line |
true |
false |
branch |
|
18
|
0 |
0 |
register_scheme(scheme, &typeid(URI), [](const URI& u)->URI*{ return new URI(u); }, default_port, secure); |
|
|
0 |
0 |
register_scheme(scheme, &typeid(URI), [](const URI& u)->URI*{ return new URI(u); }, default_port, secure); |
|
22
|
117 |
0 |
if (scheme_map.find(scheme) != scheme_map.end()) |
|
|
0 |
117 |
if (scheme_map.find(scheme) != scheme_map.end()) |
|
23
|
0 |
0 |
throw std::invalid_argument("URI::register_scheme: scheme '" + scheme + "' has been already registered"); |
|
|
0 |
0 |
throw std::invalid_argument("URI::register_scheme: scheme '" + scheme + "' has been already registered"); |
|
|
0 |
0 |
throw std::invalid_argument("URI::register_scheme: scheme '" + scheme + "' has been already registered"); |
|
|
0 |
0 |
throw std::invalid_argument("URI::register_scheme: scheme '" + scheme + "' has been already registered"); |
|
32
|
117 |
0 |
schemas.push_back(&inf); |
|
37
|
13 |
0 |
URI::register_scheme("http", &typeid(URI::http), [](const URI& u)->URI*{ return new URI::http(u); }, 80 ); |
|
|
11 |
0 |
URI::register_scheme("http", &typeid(URI::http), [](const URI& u)->URI*{ return new URI::http(u); }, 80 ); |
|
38
|
13 |
0 |
URI::register_scheme("https", &typeid(URI::https), [](const URI& u)->URI*{ return new URI::https(u); }, 443, true); |
|
|
1 |
0 |
URI::register_scheme("https", &typeid(URI::https), [](const URI& u)->URI*{ return new URI::https(u); }, 443, true); |
|
39
|
13 |
0 |
URI::register_scheme("ws", &typeid(URI::ws), [](const URI& u)->URI*{ return new URI::ws(u); }, 80 ); |
|
|
1 |
0 |
URI::register_scheme("ws", &typeid(URI::ws), [](const URI& u)->URI*{ return new URI::ws(u); }, 80 ); |
|
40
|
13 |
0 |
URI::register_scheme("wss", &typeid(URI::wss), [](const URI& u)->URI*{ return new URI::wss(u); }, 443, true); |
|
|
1 |
0 |
URI::register_scheme("wss", &typeid(URI::wss), [](const URI& u)->URI*{ return new URI::wss(u); }, 443, true); |
|
41
|
13 |
0 |
URI::register_scheme("ftp", &typeid(URI::ftp), [](const URI& u)->URI*{ return new URI::ftp(u); }, 21 ); |
|
|
1 |
0 |
URI::register_scheme("ftp", &typeid(URI::ftp), [](const URI& u)->URI*{ return new URI::ftp(u); }, 21 ); |
|
42
|
13 |
0 |
URI::register_scheme("socks5", &typeid(URI::socks), [](const URI& u)->URI*{ return new URI::socks(u); }, 1080 ); |
|
|
1 |
0 |
URI::register_scheme("socks5", &typeid(URI::socks), [](const URI& u)->URI*{ return new URI::socks(u); }, 1080 ); |
|
43
|
13 |
0 |
URI::register_scheme("ssh", &typeid(URI::ssh), [](const URI& u)->URI*{ return new URI::ssh(u); }, 22, true); |
|
|
1 |
0 |
URI::register_scheme("ssh", &typeid(URI::ssh), [](const URI& u)->URI*{ return new URI::ssh(u); }, 22, true); |
|
44
|
13 |
0 |
URI::register_scheme("telnet", &typeid(URI::telnet), [](const URI& u)->URI*{ return new URI::telnet(u); }, 23 ); |
|
|
1 |
0 |
URI::register_scheme("telnet", &typeid(URI::telnet), [](const URI& u)->URI*{ return new URI::telnet(u); }, 23 ); |
|
45
|
13 |
0 |
URI::register_scheme("sftp", &typeid(URI::sftp), [](const URI& u)->URI*{ return new URI::sftp(u); }, 22, true); |
|
|
1 |
0 |
URI::register_scheme("sftp", &typeid(URI::sftp), [](const URI& u)->URI*{ return new URI::sftp(u); }, 22, true); |
|
47
|
13 |
0 |
http_si = &scheme_map.find("http")->second; |
|
48
|
13 |
0 |
https_si = &scheme_map.find("https")->second; |
|
56
|
145 |
1 |
bool ok = !(_flags & Flags::allow_extended_chars) ? _parse(str, authority_has_pct) : _parse_ext(str, authority_has_pct); |
|
|
145 |
0 |
bool ok = !(_flags & Flags::allow_extended_chars) ? _parse(str, authority_has_pct) : _parse_ext(str, authority_has_pct); |
|
|
1 |
0 |
bool ok = !(_flags & Flags::allow_extended_chars) ? _parse(str, authority_has_pct) : _parse_ext(str, authority_has_pct); |
|
58
|
7 |
139 |
if (!ok) { |
|
59
|
7 |
0 |
clear(); |
|
63
|
0 |
139 |
if (authority_has_pct) { |
|
64
|
0 |
0 |
decode_uri_component(_user_info, _user_info); |
|
65
|
0 |
0 |
decode_uri_component(_host, _host); |
|
68
|
39 |
100 |
if (_qstr) ok_qstr(); |
|
69
|
9 |
130 |
if (_flags & Flags::allow_suffix_reference && !_host.length()) guess_suffix_reference(); |
|
|
9 |
0 |
if (_flags & Flags::allow_suffix_reference && !_host.length()) guess_suffix_reference(); |
|
|
9 |
130 |
if (_flags & Flags::allow_suffix_reference && !_host.length()) guess_suffix_reference(); |
|
|
9 |
0 |
if (_flags & Flags::allow_suffix_reference && !_host.length()) guess_suffix_reference(); |
|
70
|
139 |
0 |
sync_scheme_info(); |
|
79
|
3 |
6 |
if (!_scheme.length()) { |
|
81
|
1 |
2 |
if (delim == string::npos) { |
|
95
|
16 |
2 |
for (; i < plen; ++i) { |
|
97
|
14 |
2 |
if (c >= '0' && c <= '9') { |
|
|
12 |
2 |
if (c >= '0' && c <= '9') { |
|
102
|
2 |
2 |
if (c != '/') { _port = 0; return; } |
|
106
|
2 |
2 |
if (!ok) return; |
|
115
|
335 |
2 |
if (!relative) approx_len += (_scheme.length()+3) + (_user_info.length()*3 + 1) + (_host.length()*3 + 6); |
|
118
|
335 |
2 |
if (!relative) { |
|
119
|
258 |
77 |
if (_scheme.length()) { |
|
120
|
258 |
0 |
str += _scheme; |
|
121
|
193 |
65 |
if (_host.length()) str += "://"; |
|
|
193 |
0 |
if (_host.length()) str += "://"; |
|
122
|
65 |
0 |
else str += ':'; |
|
124
|
52 |
25 |
else if (_host.length()) str += "//"; |
|
|
52 |
0 |
else if (_host.length()) str += "//"; |
|
126
|
245 |
90 |
if (_host.length()) { |
|
127
|
50 |
195 |
if (_user_info.length()) { |
|
128
|
50 |
0 |
_encode_uri_component_append(_user_info, str, URIComponent::user_info); |
|
129
|
50 |
0 |
str += '@'; |
|
133
|
35 |
210 |
if (chost.front() == '[' && chost.back() == ']') str += _host; |
|
|
35 |
0 |
if (chost.front() == '[' && chost.back() == ']') str += _host; |
|
|
35 |
210 |
if (chost.front() == '[' && chost.back() == ']') str += _host; |
|
|
35 |
0 |
if (chost.front() == '[' && chost.back() == ']') str += _host; |
|
134
|
210 |
0 |
else _encode_uri_component_append(_host, str, URIComponent::host); |
|
136
|
65 |
180 |
if (_port) { |
|
137
|
65 |
0 |
str += ':'; |
|
138
|
65 |
0 |
str += string::from_number(_port); |
|
|
65 |
0 |
str += string::from_number(_port); |
|
143
|
185 |
152 |
if (_path.length()) str += _path; |
|
|
185 |
0 |
if (_path.length()) str += _path; |
|
144
|
2 |
150 |
else if (relative) str += '/'; // relative path MUST NOT be empty |
|
|
2 |
0 |
else if (relative) str += '/'; // relative path MUST NOT be empty |
|
146
|
103 |
234 |
if (_qstr.length()) { |
|
147
|
103 |
0 |
str += '?'; |
|
148
|
103 |
0 |
str += _qstr; // as is, because already encoded either by raw_query setter or by compile_query |
|
151
|
98 |
239 |
if (_fragment.length()) { |
|
152
|
98 |
0 |
str += '#'; |
|
153
|
98 |
0 |
str += _fragment; |
|
165
|
1 |
8 |
const char delim = _flags & Flags::query_param_semicolon ? ';' : '&'; |
|
170
|
8 |
1 |
if (len) for (int i = 0; i <= len; ++i) { |
|
|
124 |
8 |
if (len) for (int i = 0; i <= len; ++i) { |
|
171
|
116 |
8 |
char c = (i == len) ? delim : str[i]; |
|
172
|
18 |
106 |
if (c == '=' && mode == PARSE_MODE_KEY) { |
|
|
18 |
0 |
if (c == '=' && mode == PARSE_MODE_KEY) { |
|
177
|
3 |
103 |
else if (c == '%') { |
|
180
|
19 |
84 |
else if (c == delim) { |
|
181
|
1 |
18 |
if (mode == PARSE_MODE_KEY) { |
|
186
|
3 |
16 |
if (has_pct) { |
|
189
|
3 |
0 |
if (klen > 0) decode_uri_component(string_view(str+key_start, klen), key); |
|
|
3 |
0 |
if (klen > 0) decode_uri_component(string_view(str+key_start, klen), key); |
|
192
|
3 |
0 |
if (vlen > 0) decode_uri_component(string_view(str+val_start, vlen), value); |
|
|
3 |
0 |
if (vlen > 0) decode_uri_component(string_view(str+val_start, vlen), value); |
|
195
|
3 |
0 |
_query.emplace(key, value); |
|
197
|
16 |
0 |
_query.emplace(_qstr.substr(key_start, key_end - key_start), _qstr.substr(val_start, i - val_start)); |
|
|
16 |
0 |
_query.emplace(_qstr.substr(key_start, key_end - key_start), _qstr.substr(val_start, i - val_start)); |
|
210
|
0 |
7 |
const char delim = _flags & Flags::query_param_semicolon ? ';' : '&'; |
|
215
|
18 |
7 |
for (auto it = begin; it != end; ++it) bufsize += (it->first.length() + it->second.length())*3 + 2; |
|
216
|
7 |
0 |
if (bufsize) --bufsize; |
|
218
|
7 |
0 |
_qstr.reserve(bufsize); |
|
220
|
7 |
0 |
char* bufp = _qstr.buf(); |
|
222
|
18 |
7 |
for (auto it = begin; it != end; ++it) { |
|
223
|
11 |
7 |
if (it != begin) *ptr++ = delim; |
|
224
|
18 |
0 |
ptr += encode_uri_component(it->first, ptr); |
|
226
|
18 |
0 |
ptr += encode_uri_component(it->second, ptr); |
|
234
|
0 |
0 |
sync_query(); |
|
236
|
0 |
0 |
for (auto it = addquery.cbegin(); it != end; ++it) _query.emplace(it->first, it->second); |
|
|
0 |
0 |
for (auto it = addquery.cbegin(); it != end; ++it) _query.emplace(it->first, it->second); |
|
242
|
1 |
4 |
if (!plen) return std::vector(); |
|
244
|
4 |
0 |
ret.reserve(7); |
|
247
|
30 |
4 |
for (size_t i = 0; i < plen; ++i) { |
|
248
|
22 |
8 |
if (p[i] != '/') continue; |
|
249
|
4 |
4 |
if (i == start) { start++; continue; } |
|
250
|
4 |
0 |
ret.push_back(decode_uri_component(string_view(p+start, i-start))); |
|
|
4 |
0 |
ret.push_back(decode_uri_component(string_view(p+start, i-start))); |
|
253
|
2 |
2 |
if (p[plen-1] != '/') ret.push_back(string(p+start, plen-start)); |
|
|
2 |
0 |
if (p[plen-1] != '/') ret.push_back(string(p+start, plen-start)); |
|
|
2 |
0 |
if (p[plen-1] != '/') ret.push_back(string(p+start, plen-start)); |
|
272
|
25 |
129 |
if (!_scheme) { |
|
278
|
105 |
24 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
105 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
18 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
42 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
42 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
42 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
105 |
24 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
87 |
42 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
0 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
0 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
0 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
|
0 |
0 |
if (len >= 4 && (_scheme[0]|0x20) == 'h' && (_scheme[1]|0x20) == 't' && (_scheme[2]|0x20) == 't' && (_scheme[3]|0x20) == 'p') { |
|
279
|
59 |
28 |
if (len == 4) { |
|
281
|
59 |
0 |
_scheme = "http"; |
|
283
|
28 |
0 |
else if (len == 5 && (_scheme[4]|0x20) == 's') { |
|
|
28 |
0 |
else if (len == 5 && (_scheme[4]|0x20) == 's') { |
|
|
28 |
0 |
else if (len == 5 && (_scheme[4]|0x20) == 's') { |
|
|
28 |
0 |
else if (len == 5 && (_scheme[4]|0x20) == 's') { |
|
|
28 |
0 |
else if (len == 5 && (_scheme[4]|0x20) == 's') { |
|
|
0 |
0 |
else if (len == 5 && (_scheme[4]|0x20) == 's') { |
|
285
|
28 |
0 |
_scheme = "https"; |
|
292
|
42 |
0 |
char* p = _scheme.buf(); |
|
294
|
160 |
42 |
for (;p != end; ++p) *p = tolower(*p); |
|
296
|
42 |
0 |
auto it = scheme_map.find(_scheme); |
|
297
|
18 |
24 |
if (it == scheme_map.cend()) scheme_info = NULL; |
|
302
|
0 |
0 |
auto it = scheme_ti_map.find(ti); |
|
303
|
0 |
0 |
return it == scheme_ti_map.end() ? nullptr : it->second; |
|
308
|
0 |
0 |
if (delim == string::npos) return _user_info; |
|
314
|
0 |
0 |
if (delim == string::npos) _user_info = user; |
|
320
|
0 |
0 |
if (delim == string::npos) return string(); |
|
326
|
0 |
0 |
if (delim == string::npos) { |
|
334
|
0 |
0 |
string tmp = uri.to_string(); |
|
335
|
0 |
0 |
return os.write(tmp.data(), tmp.length()); |
|
338
|
13 |
0 |
}} |
|
|
13 |
0 |
}} |