mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Enhancements
Read template_args from root in TOML preferences (#717). Make max_workers work for httplib. Fix implementation of str_icase_map for HTTP headers.
This commit is contained in:
parent
9e66b07251
commit
0f2cefd537
@ -1167,7 +1167,7 @@ int loadExternalTOML(toml::value &root, ExternalConfig &ext)
|
||||
"exclude_remarks", ext.exclude
|
||||
);
|
||||
|
||||
if(ext.tpl_args != nullptr) operate_toml_kv_table(toml::find_or<std::vector<toml::table>>(section, "template_args", {}), "key", "value",
|
||||
if(ext.tpl_args != nullptr) operate_toml_kv_table(toml::find_or<std::vector<toml::table>>(root, "template_args", {}), "key", "value",
|
||||
[&](const toml::value &key, const toml::value &value)
|
||||
{
|
||||
std::string val = toml::format(value);
|
||||
|
||||
@ -187,7 +187,7 @@ int WebServer::start_web_server_multi(listener_args *args)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(e);
|
||||
if (e) std::rethrow_exception(e);
|
||||
}
|
||||
catch (const httplib::Error &err)
|
||||
{
|
||||
@ -212,6 +212,9 @@ int WebServer::start_web_server_multi(listener_args *args)
|
||||
{
|
||||
server.set_mount_point("/", serve_file_root);
|
||||
}
|
||||
server.new_task_queue = [args] {
|
||||
return new httplib::ThreadPool(args->max_workers);
|
||||
};
|
||||
server.bind_to_port(args->listen_address, args->port, 0);
|
||||
|
||||
std::thread thread([&]()
|
||||
|
||||
@ -3,13 +3,18 @@
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
struct strICaseComp
|
||||
{
|
||||
bool operator() (const std::string &lhs, const std::string &rhs) const
|
||||
{
|
||||
return strcasecmp(lhs.c_str(), rhs.c_str());
|
||||
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(),
|
||||
rhs.end(),
|
||||
[](unsigned char c1, unsigned char c2)
|
||||
{
|
||||
return ::tolower(c1) < ::tolower(c2);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user