Fix handling of post requests

This commit is contained in:
badaix 2021-06-10 12:26:12 +02:00
parent 0807641984
commit 017ab24c0b

View file

@ -220,15 +220,16 @@ void ControlSessionHttp::handle_request(http::request<Body, http::basic_fields<A
if (req.target() != "/jsonrpc")
return send(bad_request("Illegal request-target"));
message_receiver_->onMessageReceived(shared_from_this(), req.body(), [req = std::move(req), send = std::move(send)](const std::string& response) {
http::response<http::string_body> res{http::status::ok, req.version()};
res.set(http::field::server, HTTP_SERVER_NAME);
res.set(http::field::content_type, "application/json");
res.keep_alive(req.keep_alive());
res.body() = response;
res.prepare_payload();
return send(std::move(res));
});
return message_receiver_->onMessageReceived(shared_from_this(), std::string(req.body()),
[req = std::move(req), send = std::move(send)](const std::string& response) {
http::response<http::string_body> res{http::status::ok, req.version()};
res.set(http::field::server, HTTP_SERVER_NAME);
res.set(http::field::content_type, "application/json");
res.keep_alive(req.keep_alive());
res.body() = response;
res.prepare_payload();
return send(std::move(res));
});
}
// Request path must be absolute and not contain "..".