| 156 | } |
| 157 | |
| 158 | static std::string canonicalize_query(std::vector<std::pair<std::string, std::string>> params) { |
| 159 | if (params.empty()) return {}; |
| 160 | std::sort(params.begin(), params.end(), [](const auto& a, const auto& b) { |
| 161 | if (a.first == b.first) { |
| 162 | return a.second < b.second; |
| 163 | } |
| 164 | return a.first < b.first; |
| 165 | }); |
| 166 | std::string query; |
| 167 | for (size_t i = 0; i < params.size(); ++i) { |
| 168 | if (i > 0) query += '&'; |
| 169 | query += httplib::encode_uri(params[i].first); |
| 170 | query += '='; |
| 171 | query += httplib::encode_uri(params[i].second); |
| 172 | } |
| 173 | return query; |
| 174 | } |
| 175 | |
| 176 | static std::string canonicalize_path(const std::string& path, const httplib::Params& params) { |
| 177 | if (params.empty()) return path; |