You've already forked cpp-httplib
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:
10
httplib.h
10
httplib.h
@ -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