mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-28 21:08:28 +00:00
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:
1 parent
0e7d2f9f93
commit
88f6245c84
2 files changed
+61
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user