fix get value function (#509)
This commit is contained in:
parent
aea60feb85
commit
812cb5bc3d
12
httplib.h
12
httplib.h
@ -2268,9 +2268,10 @@ inline bool has_header(const Headers &headers, const char *key) {
|
|||||||
|
|
||||||
inline const char *get_header_value(const Headers &headers, const char *key,
|
inline const char *get_header_value(const Headers &headers, const char *key,
|
||||||
size_t id = 0, const char *def = nullptr) {
|
size_t id = 0, const char *def = nullptr) {
|
||||||
auto it = headers.find(key);
|
auto itRange = headers.equal_range(key);
|
||||||
std::advance(it, static_cast<int>(id));
|
auto it = itRange.first;
|
||||||
if (it != headers.end()) { return it->second.c_str(); }
|
std::advance(it, static_cast<ssize_t>(id));
|
||||||
|
if(it != itRange.second) { return it->second.c_str(); }
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3291,9 +3292,10 @@ inline bool Request::has_param(const char *key) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline std::string Request::get_param_value(const char *key, size_t id) const {
|
inline std::string Request::get_param_value(const char *key, size_t id) const {
|
||||||
auto it = params.find(key);
|
auto itRange = params.equal_range(key);
|
||||||
|
auto it = itRange.first;
|
||||||
std::advance(it, static_cast<ssize_t>(id));
|
std::advance(it, static_cast<ssize_t>(id));
|
||||||
if (it != params.end()) { return it->second; }
|
if(it != itRange.second) { return it->second; }
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user