summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_req_resp_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc-server/trex_rpc_req_resp_server.cpp')
-rw-r--r--src/rpc-server/trex_rpc_req_resp_server.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/rpc-server/trex_rpc_req_resp_server.cpp b/src/rpc-server/trex_rpc_req_resp_server.cpp
index 729917c0..e762b8c1 100644
--- a/src/rpc-server/trex_rpc_req_resp_server.cpp
+++ b/src/rpc-server/trex_rpc_req_resp_server.cpp
@@ -172,13 +172,12 @@ void TrexRpcServerReqRes::handle_request(const std::string &request) {
std::string response;
if ( request.size() > MAX_RPC_MSG_LEN ) {
- response = "Request is too large (" + std::to_string(request.size()) + " bytes). Consider splitting to smaller chunks.";
- handle_server_error(response);
- return;
+ std::string err_msg = "Request is too large (" + std::to_string(request.size()) + " bytes). Consider splitting to smaller chunks.";
+ TrexJsonRpcV2Parser::generate_common_error(response, err_msg);
+ } else {
+ process_request(request, response);
}
- process_request(request, response);
-
zmq_send(m_socket, response.c_str(), response.size(), 0);
}
@@ -250,7 +249,12 @@ void TrexRpcServerReqRes::process_zipped_request(const std::string &request, std
/* process the request */
std::string raw_response;
- process_request_raw(unzipped, raw_response);
+ if ( unzipped.size() > MAX_RPC_MSG_LEN ) {
+ std::string err_msg = "Request is too large (" + std::to_string(unzipped.size()) + " bytes). Consider splitting to smaller chunks.";
+ TrexJsonRpcV2Parser::generate_common_error(raw_response, err_msg);
+ } else {
+ process_request_raw(unzipped, raw_response);
+ }
TrexRpcZip::compress(raw_response, response);
@@ -262,18 +266,14 @@ void TrexRpcServerReqRes::process_zipped_request(const std::string &request, std
*/
void
TrexRpcServerReqRes::handle_server_error(const std::string &specific_err) {
- Json::FastWriter writer;
- Json::Value response;
+ std::string response;
/* generate error */
TrexJsonRpcV2Parser::generate_common_error(response, specific_err);
- /* write the JSON to string and sever on ZMQ */
- std::string response_str = writer.write(response);
-
- verbose_json("Server Replied: ", response_str);
+ verbose_json("Server Replied: ", response);
- zmq_send(m_socket, response_str.c_str(), response_str.size(), 0);
+ zmq_send(m_socket, response.c_str(), response.size(), 0);
}