I have the latest restbed version, without operating on the lambda body parameter, whenever you use http to upload large space in form-data, the memory occupied by the service application will grow, and it will only increase and will not go up and down
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include "router/dynamic/image.h"
#include "entity/response.h"
using namespace colnago::router;
using namespace std;
using namespace colnago::entity;
/**
* @brief POST /image
*
* @param session
*/
void image::POST(const std::shared_ptr<restbed::Session> session)
{
const auto request = session->get_request();
long long int content_length = stoll(request->get_header("Content-Length", "0"));
string content_type = request->get_header("Content-Type");
size_t i = content_type.find("multipart/form-data;");
if (i == 0)
{
content_type.erase(i, strlen("multipart/form-data;"));
}
i = content_type.find_first_not_of(' ');
if (i != string::npos)
{
content_type.erase(0, i);
}
i = content_type.find_first_of("boundary=");
if (i == 0)
{
content_type.erase(i, strlen("boundary="));
}
string slice_line = string("--") + content_type + "\r";
string end_line = string("--") + content_type + "--\r";
auto handler = [slice_line, end_line, content_type](const std::shared_ptr<restbed::Session> session, const restbed::Bytes &body) -> void
{
session->close(restbed::OK, "post success", {{"Content-Type", "text/text"}});
};
session->fetch(content_length, handler);
}
std::shared_ptr<restbed::Resource> image::resource()
{
const char *postRestFul = "/image";
auto resource = make_shared<restbed::Resource>();
resource->set_path(postRestFul);
resource->set_method_handler("POST", POST);
return resource;
}
I have the latest restbed version, without operating on the lambda body parameter, whenever you use http to upload large space in form-data, the memory occupied by the service application will grow, and it will only increase and will not go up and down