mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +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:
parent
0e7d2f9f93
commit
88f6245c84
2 changed files with 61 additions and 0 deletions
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue