mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Enhancements
Fix request arguments to alias are not passed to redirect location (#681). Fix crash if name argument is missing in getProfile interface. Fix bad webGet retry logic.
This commit is contained in:
parent
d9ff11146d
commit
2f820b81c4
@ -1162,13 +1162,13 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
|
||||
|
||||
std::string name = urlDecode(getUrlArg(argument, "name")), token = urlDecode(getUrlArg(argument, "token"));
|
||||
string_array profiles = split(name, "|");
|
||||
name = profiles[0];
|
||||
if(token.empty() || name.empty())
|
||||
if(token.empty() || profiles.empty())
|
||||
{
|
||||
*status_code = 403;
|
||||
return "Forbidden";
|
||||
}
|
||||
std::string profile_content;
|
||||
name = profiles[0];
|
||||
/*if(vfs::vfs_exist(name))
|
||||
{
|
||||
profile_content = vfs::vfs_get(name);
|
||||
|
||||
@ -252,7 +252,7 @@ static int curlGet(const FetchArgument &argument, FetchResult &result)
|
||||
while(true)
|
||||
{
|
||||
retVal = curl_easy_perform(curl_handle);
|
||||
if(retVal == CURLE_OK || max_fails >= fail_count)
|
||||
if(retVal == CURLE_OK || max_fails <= fail_count)
|
||||
break;
|
||||
else
|
||||
fail_count++;
|
||||
|
||||
@ -155,7 +155,19 @@ int WebServer::start_web_server_multi(listener_args *args)
|
||||
for (auto &x : redirect_map)
|
||||
{
|
||||
server.Get(x.first, [x](const httplib::Request &req, httplib::Response &res) {
|
||||
res.set_redirect(x.second);
|
||||
auto arguments = req.params;
|
||||
auto query = x.second;
|
||||
auto pos = query.find('?');
|
||||
query += pos == std::string::npos ? '?' : '&';
|
||||
for (auto &p: arguments)
|
||||
{
|
||||
query += p.first + "=" + urlEncode(p.second) + "&";
|
||||
}
|
||||
if (!query.empty())
|
||||
{
|
||||
query.pop_back();
|
||||
}
|
||||
res.set_redirect(query);
|
||||
});
|
||||
}
|
||||
server.set_exception_handler([](const httplib::Request &req, httplib::Response &res, const std::exception_ptr &e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user