reuse str_to_lower from server-models

This commit is contained in:
Xuan Son Nguyen
2026-08-02 20:41:31 +02:00
parent 9da937689f
commit ddd9cdb158
+8 -1
View File
@@ -1202,9 +1202,16 @@ static std::vector<std::unique_ptr<server_tool>> build_tools() {
return tools;
}
static std::string str_to_lower(const std::string & value) {
std::string lowered(value.size(), '\0');
std::transform(value.begin(), value.end(), lowered.begin(), [](unsigned char c) { return std::tolower(c); });
return lowered;
}
static std::string get_header(const std::map<std::string, std::string> & headers, const std::string & key, std::string default_value = "") {
const auto lowered_key = str_to_lower(key);
for (const auto & h : headers) {
if (strcasecmp(h.first.c_str(), key.c_str()) == 0) {
if (str_to_lower(h.first) == lowered_key) {
return h.second;
}
}