mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-09-26 23:09:20 +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;
|
||||
std::string proxy = parseProxy(global.proxySubscription);
|
||||
Request request;
|
||||
Response response;
|
||||
for(std::string &x : sections)
|
||||
{
|
||||
Request request;
|
||||
Response response;
|
||||
response.status_code = 200;
|
||||
//std::cerr<<"Generating artifact '"<<x<<"'...\n";
|
||||
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");
|
||||
if(type == "form")
|
||||
fileWrite(global.prefPath, getFormData(request.postdata), true);
|
||||
else if(type == "direct")
|
||||
if(type == "form" || type == "direct")
|
||||
{
|
||||
fileWrite(global.prefPath, request.postdata, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
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.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);
|
||||
}
|
||||
else
|
||||
{
|
||||
req.postdata = request.body;
|
||||
if (request.is_multipart_form_data() && !request.files.empty())
|
||||
{
|
||||
req.postdata = request.files.begin()->second.content;
|
||||
}
|
||||
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);
|
||||
response.status = resp.status_code;
|
||||
|
Loading…
Reference in New Issue
Block a user