Committing updates.
This commit is contained in:
@@ -316,10 +316,10 @@ namespace Apostol {
|
||||
chASSERT(pClient);
|
||||
auto pContext = pClient->Context();
|
||||
chASSERT(pContext);
|
||||
auto pReply = pConnection->Reply();
|
||||
const auto &Reply = pConnection->Reply();
|
||||
|
||||
if (pReply->Status == CHTTPReply::moved_permanently || pReply->Status == CHTTPReply::moved_temporarily) {
|
||||
const auto &caLocation = pReply->Headers["Location"];
|
||||
if (Reply.Status == CHTTPReply::moved_permanently || Reply.Status == CHTTPReply::moved_temporarily) {
|
||||
const auto &caLocation = Reply.Headers["Location"];
|
||||
if (!caLocation.IsEmpty()) {
|
||||
pClient->SetURI(CLocation(caLocation));
|
||||
Log()->Notice(_T("[%s] Redirect to %s."), pClient->Session().c_str(), pClient->URI().href().c_str());
|
||||
@@ -346,37 +346,37 @@ namespace Apostol {
|
||||
void CWebSocketModule::DoAccount(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
||||
|
||||
auto OnRequest = [AConnection](CWebSocketMessageHandler *AHandler, CWebSocketConnection *AWSConnection) {
|
||||
auto pReply = AConnection->Reply();
|
||||
auto &Reply = AConnection->Reply();
|
||||
const auto &wsMessage = CCustomWebSocketClient::RequestToMessage(AWSConnection);
|
||||
pReply->ContentType = CHTTPReply::json;
|
||||
Reply.ContentType = CHTTPReply::json;
|
||||
if (wsMessage.MessageTypeId == mtCallResult) {
|
||||
pReply->Content = wsMessage.Payload.ToString();
|
||||
Reply.Content = wsMessage.Payload.ToString();
|
||||
AConnection->SendReply(CHTTPReply::ok, nullptr, true);
|
||||
} else {
|
||||
ReplyError(AConnection, CHTTPReply::bad_request, wsMessage.ErrorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
auto pServerRequest = AConnection->Request();
|
||||
const auto &ServerRequest = AConnection->Request();
|
||||
|
||||
const auto &caModuleAddress = m_Module["address"];
|
||||
const auto &caHost = pServerRequest->Headers["host"];
|
||||
const auto &caOrigin = pServerRequest->Headers["origin"];
|
||||
const auto &caUserAddress = GetAddress(pServerRequest);
|
||||
const auto &caHost = ServerRequest.Headers["host"];
|
||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
||||
const auto &caUserAddress = GetAddress(ServerRequest);
|
||||
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
||||
const auto &caServerParam = ServerRequest.Params["server"];
|
||||
|
||||
CStringList caClearText;
|
||||
CString sPayload;
|
||||
|
||||
if (!pServerRequest->Content.IsEmpty()) {
|
||||
if (!ServerRequest.Content.IsEmpty()) {
|
||||
|
||||
const auto &ContentType = pServerRequest->Headers.Values(_T("content-type"));
|
||||
const auto &ContentType = ServerRequest.Headers.Values(_T("content-type"));
|
||||
|
||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||
|
||||
const CStringList &FormData = pServerRequest->FormData;
|
||||
const CStringList &FormData = ServerRequest.FormData;
|
||||
|
||||
const auto &formDate = FormData["date"];
|
||||
const auto &formAddress = FormData["address"];
|
||||
@@ -422,7 +422,7 @@ namespace Apostol {
|
||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||
|
||||
CFormData FormData;
|
||||
CHTTPRequestParser::ParseFormData(pServerRequest, FormData);
|
||||
CHTTPRequestParser::ParseFormData(ServerRequest, FormData);
|
||||
|
||||
const auto &formDate = FormData.Data("date");
|
||||
const auto &formAddress = FormData.Data("address");
|
||||
@@ -467,7 +467,7 @@ namespace Apostol {
|
||||
|
||||
} else if (ContentType.Find("application/json") == 0) {
|
||||
|
||||
const CJSON contextJson(pServerRequest->Content);
|
||||
const CJSON contextJson(ServerRequest.Content);
|
||||
|
||||
const auto &jsonDate = contextJson["date"].AsString();
|
||||
const auto &jsonAddress = contextJson["address"].AsString();
|
||||
@@ -514,7 +514,7 @@ namespace Apostol {
|
||||
}
|
||||
|
||||
} else {
|
||||
caClearText = pServerRequest->Content;
|
||||
caClearText = ServerRequest.Content;
|
||||
}
|
||||
|
||||
if (pgpValue == "off" || pgpValue == "false") {
|
||||
@@ -560,18 +560,18 @@ namespace Apostol {
|
||||
void CWebSocketModule::DoDeal(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI, const CString &Action) {
|
||||
|
||||
auto OnRequest = [AConnection](CWebSocketMessageHandler *AHandler, CWebSocketConnection *AWSConnection) {
|
||||
auto pReply = AConnection->Reply();
|
||||
auto &Reply = AConnection->Reply();
|
||||
const auto &wsMessage = CCustomWebSocketClient::RequestToMessage(AWSConnection);
|
||||
pReply->ContentType = CHTTPReply::json;
|
||||
Reply.ContentType = CHTTPReply::json;
|
||||
if (wsMessage.MessageTypeId == mtCallResult) {
|
||||
pReply->Content = wsMessage.Payload.ToString();
|
||||
Reply.Content = wsMessage.Payload.ToString();
|
||||
AConnection->SendReply(CHTTPReply::ok, nullptr, true);
|
||||
} else {
|
||||
ReplyError(AConnection, CHTTPReply::bad_request, wsMessage.ErrorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
auto pServerRequest = AConnection->Request();
|
||||
const auto &ServerRequest = AConnection->Request();
|
||||
|
||||
const auto &caModuleAddress = m_Module["address"];
|
||||
const auto &caModuleFee = m_Module["fee"];
|
||||
@@ -580,17 +580,17 @@ namespace Apostol {
|
||||
if (checkFee == -1)
|
||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||
|
||||
const auto &caHost = pServerRequest->Headers["host"];
|
||||
const auto &caOrigin = pServerRequest->Headers["origin"];
|
||||
const auto &caHost = ServerRequest.Headers["host"];
|
||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
||||
|
||||
const auto &address = GetAddress(pServerRequest);
|
||||
const auto &code = pServerRequest->Params["code"];
|
||||
const auto &address = GetAddress(ServerRequest);
|
||||
const auto &code = ServerRequest.Params["code"];
|
||||
|
||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
||||
const auto &caServerParam = ServerRequest.Params["server"];
|
||||
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
if (index == -1) {
|
||||
@@ -603,14 +603,14 @@ namespace Apostol {
|
||||
|
||||
CString sPayload;
|
||||
|
||||
if (!pServerRequest->Content.IsEmpty() && Action != "status") {
|
||||
if (!ServerRequest.Content.IsEmpty() && Action != "status") {
|
||||
|
||||
const auto utc = UTC();
|
||||
const auto &ContentType = pServerRequest->Headers.Values(_T("content-type"));
|
||||
const auto &ContentType = ServerRequest.Headers.Values(_T("content-type"));
|
||||
|
||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||
|
||||
const CStringList &FormData = pServerRequest->FormData;
|
||||
const CStringList &FormData = ServerRequest.FormData;
|
||||
|
||||
const auto &formType = FormData["type"];
|
||||
const auto &formAt = FormData["at"];
|
||||
@@ -697,7 +697,7 @@ namespace Apostol {
|
||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||
|
||||
CFormData FormData;
|
||||
CHTTPRequestParser::ParseFormData(pServerRequest, FormData);
|
||||
CHTTPRequestParser::ParseFormData(ServerRequest, FormData);
|
||||
|
||||
const auto &formType = FormData.Data("type");
|
||||
const auto &formAt = FormData.Data("at");
|
||||
@@ -783,7 +783,7 @@ namespace Apostol {
|
||||
|
||||
} else if (ContentType.Find("application/json") == 0) {
|
||||
|
||||
const CJSON jsonData(pServerRequest->Content);
|
||||
const CJSON jsonData(ServerRequest.Content);
|
||||
|
||||
const auto &formOrder = jsonData["order"].AsString().Lower();
|
||||
const auto &formType = jsonData["type"].AsString();
|
||||
@@ -878,7 +878,7 @@ namespace Apostol {
|
||||
}
|
||||
|
||||
} else {
|
||||
Node = YAML::Load(pServerRequest->Content.c_str());
|
||||
Node = YAML::Load(ServerRequest.Content.c_str());
|
||||
}
|
||||
|
||||
const auto &BTCKeys = caContext.BTCKeys();
|
||||
@@ -968,18 +968,18 @@ namespace Apostol {
|
||||
void CWebSocketModule::DoProxy(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
||||
|
||||
auto OnRequest = [AConnection](CWebSocketMessageHandler *AHandler, CWebSocketConnection *AWSConnection) {
|
||||
auto pReply = AConnection->Reply();
|
||||
auto &Reply = AConnection->Reply();
|
||||
const auto &wsMessage = CCustomWebSocketClient::RequestToMessage(AWSConnection);
|
||||
pReply->ContentType = CHTTPReply::json;
|
||||
Reply.ContentType = CHTTPReply::json;
|
||||
if (wsMessage.MessageTypeId == mtCallResult) {
|
||||
pReply->Content = wsMessage.Payload.ToString();
|
||||
Reply.Content = wsMessage.Payload.ToString();
|
||||
AConnection->SendReply(CHTTPReply::ok, nullptr, true);
|
||||
} else {
|
||||
ReplyError(AConnection, CHTTPReply::bad_request, wsMessage.ErrorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
auto pServerRequest = AConnection->Request();
|
||||
const auto &ServerRequest = AConnection->Request();
|
||||
|
||||
const auto &caModuleAddress = m_Module["address"];
|
||||
const auto &caModuleFee = m_Module["fee"];
|
||||
@@ -988,17 +988,17 @@ namespace Apostol {
|
||||
if (checkFee == -1)
|
||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||
|
||||
const auto &caHost = pServerRequest->Headers["host"];
|
||||
const auto &caOrigin = pServerRequest->Headers["origin"];
|
||||
const auto &caHost = ServerRequest.Headers["host"];
|
||||
const auto &caOrigin = ServerRequest.Headers["origin"];
|
||||
|
||||
const auto &address = pServerRequest->Params["address"];
|
||||
const auto &code = pServerRequest->Params["code"];
|
||||
const auto &address = ServerRequest.Params["address"];
|
||||
const auto &code = ServerRequest.Params["code"];
|
||||
|
||||
const auto &caUserAddress = address.length() == 40 ? CString() : address;
|
||||
const auto &caDealCode = !code.empty() ? code : address.length() == 40 ? address : CString();
|
||||
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
const auto &pgpValue = ServerRequest.Params["pgp"];
|
||||
const auto &caServerParam = ServerRequest.Params["server"];
|
||||
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
if (index == -1) {
|
||||
@@ -1013,22 +1013,22 @@ namespace Apostol {
|
||||
throw Delphi::Exception::Exception(NOT_FOUND_ACTIVE_CONNECTION);
|
||||
}
|
||||
|
||||
const CJSON Json(pServerRequest->Content);
|
||||
const CJSON Json(ServerRequest.Content);
|
||||
|
||||
pClient->Send(URI, Json, OnRequest);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void CWebSocketModule::DoSignature(CHTTPServerConnection *AConnection) {
|
||||
auto pRequest = AConnection->Request();
|
||||
auto pReply = AConnection->Reply();
|
||||
const auto &caRequest = AConnection->Request();
|
||||
auto &Reply = AConnection->Reply();
|
||||
|
||||
if (pRequest->Content.IsEmpty()) {
|
||||
if (caRequest.Content.IsEmpty()) {
|
||||
AConnection->SendStockReply(CHTTPReply::no_content);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &caServerParam = pRequest->Params["server"];
|
||||
const auto &caServerParam = caRequest.Params["server"];
|
||||
|
||||
int index = CurrentContextIndex(caServerParam);
|
||||
if (index == -1) {
|
||||
@@ -1054,10 +1054,10 @@ namespace Apostol {
|
||||
CString message;
|
||||
CJSON Json(jvtObject);
|
||||
|
||||
const auto& caContentType = pRequest->Headers["content-type"];
|
||||
const auto& caContentType = caRequest.Headers["content-type"];
|
||||
|
||||
if (caContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||
const CStringList &FormData = pRequest->FormData;
|
||||
const CStringList &FormData = caRequest.FormData;
|
||||
|
||||
const auto& caClearText = FormData["message"];
|
||||
CheckKeyForNull("message", caClearText.c_str());
|
||||
@@ -1066,7 +1066,7 @@ namespace Apostol {
|
||||
Json.Object().AddPair("verified", bVerified);
|
||||
} else if (caContentType.Find("multipart/form-data") == 0) {
|
||||
CFormData FormData;
|
||||
CHTTPRequestParser::ParseFormData(pRequest, FormData);
|
||||
CHTTPRequestParser::ParseFormData(caRequest, FormData);
|
||||
|
||||
const auto& caClearText = FormData.Data("message");
|
||||
CheckKeyForNull("message", caClearText.c_str());
|
||||
@@ -1074,7 +1074,7 @@ namespace Apostol {
|
||||
const auto bVerified = CheckVerifyPGPSignature(VerifyPGPSignature(caClearText, caServerKey, message), message);
|
||||
Json.Object().AddPair("verified", bVerified);
|
||||
} else if (caContentType.Find("application/json") == 0) {
|
||||
const CJSON jsonData(pRequest->Content);
|
||||
const CJSON jsonData(caRequest.Content);
|
||||
|
||||
const auto& caClearText = jsonData["message"].AsString();
|
||||
CheckKeyForNull("message", caClearText.c_str());
|
||||
@@ -1082,7 +1082,7 @@ namespace Apostol {
|
||||
const auto bVerified = CheckVerifyPGPSignature(VerifyPGPSignature(caClearText, caServerKey, message), message);
|
||||
Json.Object().AddPair("verified", bVerified);
|
||||
} else {
|
||||
const auto& caClearText = pRequest->Content;
|
||||
const auto& caClearText = caRequest.Content;
|
||||
const auto bVerified = CheckVerifyPGPSignature(VerifyPGPSignature(caClearText, caServerKey, message), message);
|
||||
Json.Object().AddPair("verified", bVerified);
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ namespace Apostol {
|
||||
Json.Object().AddPair("message", message);
|
||||
|
||||
AConnection->CloseConnection(true);
|
||||
pReply->Content << Json;
|
||||
Reply.Content << Json;
|
||||
|
||||
AConnection->SendReply(CHTTPReply::ok);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user