feat: Add Request::get_file_multi_value func. (#1495)

Support to get multiple values of a key.

perf: Rename function names, variable names etc.
This commit is contained in:
jingTian-z 2023-02-17 10:51:06 +08:00 committed by GitHub
parent 0e7d2f9f93
commit 88f6245c84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 0 deletions

View file

@ -454,6 +454,7 @@ struct Request {
bool has_file(const std::string &key) const;
MultipartFormData get_file_value(const std::string &key) const;
std::vector<MultipartFormData> get_file_values(const std::string &key) const;
// private members...
size_t redirect_count_ = CPPHTTPLIB_REDIRECT_MAX_COUNT;
@ -4690,6 +4691,15 @@ inline MultipartFormData Request::get_file_value(const std::string &key) const {
return MultipartFormData();
}
inline std::vector<MultipartFormData> Request::get_file_values(const std::string &key) const {
std::vector<MultipartFormData> values;
auto rng = files.equal_range(key);
for (auto it = rng.first; it != rng.second; it++) {
values.push_back(it->second);
}
return values;
}
// Response implementation
inline bool Response::has_header(const std::string &key) const {
return headers.find(key) != headers.end();