diff --git a/dependencies/mariadb-connector-c b/dependencies/mariadb-connector-c index 1f7480118..159540fe8 160000 --- a/dependencies/mariadb-connector-c +++ b/dependencies/mariadb-connector-c @@ -1 +1 @@ -Subproject commit 1f7480118acfe12be9e356827aa30ae9b9eca9a7 +Subproject commit 159540fe8c8f30b281748fe8a1b79e8b17993a67 diff --git a/src/cpp/lib/JsonRequest.cpp b/src/cpp/lib/JsonRequest.cpp index 825d30f66..fa12de0b9 100644 --- a/src/cpp/lib/JsonRequest.cpp +++ b/src/cpp/lib/JsonRequest.cpp @@ -192,93 +192,3 @@ JsonRequestReturn JsonRequest::requestGRPCRelay(const Poco::Net::NameValueCollec return JSON_REQUEST_RETURN_OK; } -#include "Poco/JSON/Stringifier.h" -JsonRequestReturn JsonRequest::requestGRPCRelay(const Poco::Net::NameValueCollection& payload) -{ - static const char* functionName = "JsonRequest::requestGRPCRelay"; - Poco::JSON::Object requestJson; - - for (auto it = payload.begin(); it != payload.end(); it++) { - requestJson.set(it->first, it->second); - } - - // send post request via https - // 443 = HTTPS Default - // TODO: adding port into ServerConfig - try { - Profiler phpRequestTime; - Poco::Net::HTTPClientSession httpClientSession(mServerHost, mServerPort); - Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/hedera_rpc_relay/gRPCProxy.php"); - - request.setChunkedTransferEncoding(false); - std::ostream& requestStream = httpClientSession.sendRequest(request); - requestJson.stringify(requestStream); - - std::stringstream ss; - requestJson.stringify(ss); - auto f = fopen("grpc.txt", "wt"); - std::string grpc = ss.str(); - fwrite(grpc.data(), grpc.size(), 1, f); - fclose(f); - - Poco::Net::HTTPResponse response; - std::istream& request_stream = httpClientSession.receiveResponse(response); - - // debugging answer - - std::stringstream responseStringStream; - for (std::string line; std::getline(request_stream, line); ) { - responseStringStream << line << std::endl; - } - Poco::Logger& speedLog = Poco::Logger::get("SpeedLog"); - speedLog.information("[gRPC relay] php server time: %s", phpRequestTime.string()); - - // extract parameter from request - Poco::JSON::Parser jsonParser; - Poco::Dynamic::Var parsedJson; - try { - parsedJson = jsonParser.parse(responseStringStream.str()); - } - catch (Poco::Exception& ex) { - addError(new ParamError(functionName, "error parsing request answer grpc relay", ex.displayText().data())); - - std::string fileName = "response_grpc_"; - fileName += ".html"; - - FILE* f = fopen(fileName.data(), "wt"); - std::string responseString = responseStringStream.str(); - fwrite(responseString.data(), 1, responseString.size(), f); - fclose(f); - // */ - sendErrorsAsEmail(responseStringStream.str()); - return JSON_REQUEST_RETURN_PARSE_ERROR; - } - - Poco::JSON::Object object = *parsedJson.extract(); - auto state = object.get("state"); - std::string stateString = state.convert(); - if (stateString == "error") { - addError(new Error(functionName, "php server return error")); - if (!object.isNull("msg")) { - addError(new ParamError(functionName, "msg:", object.get("msg").convert().data())); - } - if (!object.isNull("details")) { - addError(new ParamError(functionName, "details:", object.get("details").convert().data())); - } - sendErrorsAsEmail(); - return JSON_REQUEST_RETURN_ERROR; - } - ss.clear(); - Poco::JSON::Stringifier::stringify(object, ss); - printf("json request result: %s\n", ss.str().data()); - } - catch (Poco::Exception& e) { - addError(new ParamError(functionName, "connect error to php server", e.displayText().data())); - sendErrorsAsEmail(); - return JSON_REQUEST_CONNECT_ERROR; - } - - - - return JSON_REQUEST_RETURN_OK; -} \ No newline at end of file diff --git a/src/proto b/src/proto index ff412f735..81a461566 160000 --- a/src/proto +++ b/src/proto @@ -1 +1 @@ -Subproject commit ff412f735667b30233c0ce00d461f209ac7dde7c +Subproject commit 81a461566e46d71533dc3e284fa075d7d68fd020