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

Function canonicalize_query

Source/Http/HttpServer.cpp:158–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static 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
176static std::string canonicalize_path(const std::string& path, const httplib::Params& params) {
177 if (params.empty()) return path;

Callers 2

canonicalize_pathFunction · 0.85
isWebSocketAuthorizedMethod · 0.85

Calls 6

encode_uriFunction · 0.85
sortFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected