mirror of
https://github.com/oxen-io/oxen-storage-server.git
synced 2023-12-13 21:00:26 +01:00
Stop processing after invoking the callback
If one of these errors were hit processing would continue, writing status/headers/body multiple times until we throw an exception, which bubbles back to the exception handler which writes the body yet another time.
This commit is contained in:
parent
670f98accd
commit
2a62b4d5d3
|
@ -357,7 +357,7 @@ void RequestHandler::process_client_req(
|
|||
const json body = json::parse(req_json, nullptr, false);
|
||||
if (body.is_discarded()) {
|
||||
OXEN_LOG(debug, "Bad client request: invalid json");
|
||||
cb(Response{Status::BAD_REQUEST, "invalid json\n"});
|
||||
return cb(Response{Status::BAD_REQUEST, "invalid json\n"});
|
||||
}
|
||||
|
||||
if (OXEN_LOG_ENABLED(trace))
|
||||
|
@ -366,7 +366,7 @@ void RequestHandler::process_client_req(
|
|||
const auto method_it = body.find("method");
|
||||
if (method_it == body.end() || !method_it->is_string()) {
|
||||
OXEN_LOG(debug, "Bad client request: no method field");
|
||||
cb(Response{Status::BAD_REQUEST, "invalid json: no `method` field\n"});
|
||||
return cb(Response{Status::BAD_REQUEST, "invalid json: no `method` field\n"});
|
||||
}
|
||||
|
||||
const auto& method_name = method_it->get_ref<const std::string&>();
|
||||
|
@ -376,7 +376,7 @@ void RequestHandler::process_client_req(
|
|||
const auto params_it = body.find("params");
|
||||
if (params_it == body.end() || !params_it->is_object()) {
|
||||
OXEN_LOG(debug, "Bad client request: no params field");
|
||||
cb(Response{Status::BAD_REQUEST, "invalid json: no `params` field\n"});
|
||||
return cb(Response{Status::BAD_REQUEST, "invalid json: no `params` field\n"});
|
||||
}
|
||||
|
||||
if (method_name == "store") {
|
||||
|
|
Loading…
Reference in a new issue