| 185 | } |
| 186 | |
| 187 | static 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 | |
| 210 | static Dictionary* makeAppWSMessage(String type, std::string&& msg = std::string{}) { |
| 211 | auto payload = Dictionary::create(); |
no test coverage detected