MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / parse_query_pairs

Function parse_query_pairs

Source/Http/HttpServer.cpp:187–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static std::vector<std::pair<std::string, std::string>> parse_query_pairs(const std::string& resource) {
188 std::vector<std::pair<std::string, std::string>> params;
189 auto qpos = resource.find('?');
190 if (qpos == std::string::npos) return params;
191 auto query = resource.substr(qpos + 1);
192 size_t start = 0;
193 while (start < query.size()) {
194 auto amp = query.find('&', start);
195 if (amp == std::string::npos) {
196 amp = query.size();
197 }
198 auto part = query.substr(start, amp - start);
199 auto eq = part.find('=');
200 if (eq != std::string::npos) {
201 auto name = httplib::decode_uri(part.substr(0, eq));
202 auto value = httplib::decode_uri(part.substr(eq + 1));
203 params.emplace_back(std::move(name), std::move(value));
204 }
205 start = amp + 1;
206 }
207 return params;
208}
209
210static Dictionary* makeAppWSMessage(String type, std::string&& msg = std::string{}) {
211 auto payload = Dictionary::create();

Callers 1

isWebSocketAuthorizedMethod · 0.85

Calls 6

decode_uriFunction · 0.85
moveFunction · 0.85
findMethod · 0.65
substrMethod · 0.65
sizeMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected