mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Enhancements
Fix not properly handling data from multipart-form POST (#739). Fix not cleaning up request parameters when generating profiles (#741).
This commit is contained in:
parent
b9ad0c2ee2
commit
0c8574755a
@ -1362,10 +1362,10 @@ int simpleGenerator()
|
|||||||
|
|
||||||
string_multimap allItems;
|
string_multimap allItems;
|
||||||
std::string proxy = parseProxy(global.proxySubscription);
|
std::string proxy = parseProxy(global.proxySubscription);
|
||||||
Request request;
|
|
||||||
Response response;
|
|
||||||
for(std::string &x : sections)
|
for(std::string &x : sections)
|
||||||
{
|
{
|
||||||
|
Request request;
|
||||||
|
Response response;
|
||||||
response.status_code = 200;
|
response.status_code = 200;
|
||||||
//std::cerr<<"Generating artifact '"<<x<<"'...\n";
|
//std::cerr<<"Generating artifact '"<<x<<"'...\n";
|
||||||
writeLog(0, "Generating artifact '" + x + "'...", LOG_LEVEL_INFO);
|
writeLog(0, "Generating artifact '" + x + "'...", LOG_LEVEL_INFO);
|
||||||
|
|||||||
@ -233,10 +233,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string type = getUrlArg(request.argument, "type");
|
std::string type = getUrlArg(request.argument, "type");
|
||||||
if(type == "form")
|
if(type == "form" || type == "direct")
|
||||||
fileWrite(global.prefPath, getFormData(request.postdata), true);
|
{
|
||||||
else if(type == "direct")
|
|
||||||
fileWrite(global.prefPath, request.postdata, true);
|
fileWrite(global.prefPath, request.postdata, true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
response.status_code = 501;
|
response.status_code = 501;
|
||||||
|
|||||||
@ -50,13 +50,20 @@ static httplib::Server::Handler makeHandler(const responseRoute &rr)
|
|||||||
req.headers.emplace(h.first.data(), h.second.data());
|
req.headers.emplace(h.first.data(), h.second.data());
|
||||||
}
|
}
|
||||||
req.argument = request.params;
|
req.argument = request.params;
|
||||||
if (request.get_header_value("Content-Type") == "application/x-www-form-urlencoded")
|
if (request.method == "POST" || request.method == "PUT" || request.method == "PATCH")
|
||||||
{
|
{
|
||||||
req.postdata = urlDecode(request.body);
|
if (request.is_multipart_form_data() && !request.files.empty())
|
||||||
}
|
{
|
||||||
else
|
req.postdata = request.files.begin()->second.content;
|
||||||
{
|
}
|
||||||
req.postdata = request.body;
|
else if (request.get_header_value("Content-Type") == "application/x-www-form-urlencoded")
|
||||||
|
{
|
||||||
|
req.postdata = urlDecode(request.body);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
req.postdata = request.body;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto result = rr.rc(req, resp);
|
auto result = rr.rc(req, resp);
|
||||||
response.status = resp.status_code;
|
response.status = resp.status_code;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user