Committing updates.
This commit is contained in:
@@ -104,31 +104,31 @@ namespace Apostol {
|
||||
|
||||
if (Assigned(pProxy) && (pProxy->Connection() != nullptr)) {
|
||||
auto pProxyConnection = pProxy->Connection();
|
||||
auto pServerRequest = pProxyConnection->Request();
|
||||
auto pServerReply = pProxyConnection->Reply();
|
||||
auto pProxyReply = pConnection->Reply();
|
||||
const auto &caServerRequest = pProxyConnection->Request();
|
||||
auto &ServerReply = pProxyConnection->Reply();
|
||||
auto &ProxyReply = pConnection->Reply();
|
||||
|
||||
const auto &caFormat = pServerRequest->Params["payload"];
|
||||
const auto &caFormat = caServerRequest.Params["payload"];
|
||||
if (!caFormat.IsEmpty()) {
|
||||
if (caFormat == "html") {
|
||||
pServerReply->ContentType = CHTTPReply::html;
|
||||
ServerReply.ContentType = CHTTPReply::html;
|
||||
} else if (caFormat == "json") {
|
||||
pServerReply->ContentType = CHTTPReply::json;
|
||||
ServerReply.ContentType = CHTTPReply::json;
|
||||
} else if (caFormat == "xml") {
|
||||
pServerReply->ContentType = CHTTPReply::xml;
|
||||
ServerReply.ContentType = CHTTPReply::xml;
|
||||
} else {
|
||||
pServerReply->ContentType = CHTTPReply::text;
|
||||
ServerReply.ContentType = CHTTPReply::text;
|
||||
}
|
||||
|
||||
if (pProxyReply->Status == CHTTPReply::ok) {
|
||||
if (!pProxyReply->Content.IsEmpty()) {
|
||||
const CJSON json(pProxyReply->Content);
|
||||
pServerReply->Content = base64_decode(json["payload"].AsString());
|
||||
if (ProxyReply.Status == CHTTPReply::ok) {
|
||||
if (!ProxyReply.Content.IsEmpty()) {
|
||||
const CJSON json(ProxyReply.Content);
|
||||
ServerReply.Content = base64_decode(json["payload"].AsString());
|
||||
}
|
||||
pProxyConnection->SendReply(pProxyReply->Status, nullptr, true);
|
||||
pProxyConnection->SendReply(ProxyReply.Status, nullptr, true);
|
||||
} else {
|
||||
if (pProxyReply->Status == CHTTPReply::forbidden) {
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
if (ProxyReply.Status == CHTTPReply::forbidden) {
|
||||
const auto &caServerParam = caServerRequest.Params["server"];
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
auto &Context = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||
@@ -137,15 +137,15 @@ namespace Apostol {
|
||||
Context.SetStatus(Context::csInitialized);
|
||||
}
|
||||
|
||||
pServerReply->Content = pProxyReply->Content;
|
||||
pProxyConnection->SendStockReply(pProxyReply->Status, true);
|
||||
ServerReply.Content = ProxyReply.Content;
|
||||
pProxyConnection->SendStockReply(ProxyReply.Status, true);
|
||||
}
|
||||
} else {
|
||||
pServerReply->Content = pProxyReply->Content;
|
||||
if (pProxyReply->Status == CHTTPReply::ok) {
|
||||
pProxyConnection->SendReply(pProxyReply->Status, nullptr, true);
|
||||
ServerReply.Content = ProxyReply.Content;
|
||||
if (ProxyReply.Status == CHTTPReply::ok) {
|
||||
pProxyConnection->SendReply(ProxyReply.Status, nullptr, true);
|
||||
} else {
|
||||
pProxyConnection->SendStockReply(pProxyReply->Status, true);
|
||||
pProxyConnection->SendStockReply(ProxyReply.Status, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,12 +162,12 @@ namespace Apostol {
|
||||
|
||||
if (Assigned(pProxy) && (pProxy->Connection() != nullptr)) {
|
||||
auto pProxyConnection = pProxy->Connection();
|
||||
auto pServerRequest = pProxyConnection->Request();
|
||||
auto pServerReply = pProxyConnection->Reply();
|
||||
const auto &caServerRequest = pProxyConnection->Request();
|
||||
auto &ServerReply = pProxyConnection->Reply();
|
||||
|
||||
const auto &Format = pServerRequest->Params["format"];
|
||||
const auto &Format = caServerRequest.Params["format"];
|
||||
if (Format == "html") {
|
||||
pServerReply->ContentType = CHTTPReply::html;
|
||||
ServerReply.ContentType = CHTTPReply::html;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -187,8 +187,8 @@ namespace Apostol {
|
||||
|
||||
if (Assigned(pProxy) && (pProxy->Connection() != nullptr)) {
|
||||
auto pProxyConnection = pProxy->Connection();
|
||||
auto pReply = pProxyConnection->Reply();
|
||||
ExceptionToJson(0, E, pReply->Content);
|
||||
auto &Reply = pProxyConnection->Reply();
|
||||
ExceptionToJson(0, E, Reply.Content);
|
||||
pProxyConnection->SendReply(CHTTPReply::internal_server_error, nullptr, true);
|
||||
}
|
||||
|
||||
@@ -244,16 +244,16 @@ namespace Apostol {
|
||||
void CWebService::DoAccount(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
||||
|
||||
auto pProxy = GetProxy(AConnection);
|
||||
auto pServerRequest = AConnection->Request();
|
||||
auto pProxyRequest = pProxy->Request();
|
||||
const auto &caServerRequest = AConnection->Request();
|
||||
auto &ProxyRequest = pProxy->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 = caServerRequest.Headers["host"];
|
||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||
const auto &caUserAddress = GetAddress(caServerRequest);
|
||||
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
const auto &pgpValue = caServerRequest.Params["pgp"];
|
||||
const auto &caServerParam = caServerRequest.Params["server"];
|
||||
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
@@ -268,13 +268,13 @@ namespace Apostol {
|
||||
CStringList caClearText;
|
||||
CString sPayload;
|
||||
|
||||
if (!pServerRequest->Content.IsEmpty()) {
|
||||
if (!caServerRequest.Content.IsEmpty()) {
|
||||
|
||||
const auto &ContentType = pServerRequest->Headers.Values(_T("content-type"));
|
||||
const auto &ContentType = caServerRequest.Headers.Values(_T("content-type"));
|
||||
|
||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||
|
||||
const CStringList &FormData = pServerRequest->FormData;
|
||||
const CStringList &FormData = caServerRequest.FormData;
|
||||
|
||||
const auto &formDate = FormData["date"];
|
||||
const auto &formAddress = FormData["address"];
|
||||
@@ -320,7 +320,7 @@ namespace Apostol {
|
||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||
|
||||
CFormData FormData;
|
||||
CHTTPRequestParser::ParseFormData(pServerRequest, FormData);
|
||||
CHTTPRequestParser::ParseFormData(caServerRequest, FormData);
|
||||
|
||||
const auto &formDate = FormData.Data("date");
|
||||
const auto &formAddress = FormData.Data("address");
|
||||
@@ -365,7 +365,7 @@ namespace Apostol {
|
||||
|
||||
} else if (ContentType.Find("application/json") == 0) {
|
||||
|
||||
const CJSON contextJson(pServerRequest->Content);
|
||||
const CJSON contextJson(caServerRequest.Content);
|
||||
|
||||
const auto &jsonDate = contextJson["date"].AsString();
|
||||
const auto &jsonAddress = contextJson["address"].AsString();
|
||||
@@ -412,7 +412,7 @@ namespace Apostol {
|
||||
}
|
||||
|
||||
} else {
|
||||
caClearText = pServerRequest->Content;
|
||||
caClearText = caServerRequest.Content;
|
||||
}
|
||||
|
||||
if (pgpValue == "off" || pgpValue == "false") {
|
||||
@@ -445,22 +445,22 @@ namespace Apostol {
|
||||
if (!sPayload.IsEmpty())
|
||||
Json.Object().AddPair("payload", base64_encode(sPayload));
|
||||
|
||||
pProxyRequest->Clear();
|
||||
ProxyRequest.Clear();
|
||||
|
||||
pProxyRequest->Location = pServerRequest->Location;
|
||||
pProxyRequest->CloseConnection = false;
|
||||
pProxyRequest->ContentType = CHTTPRequest::json;
|
||||
pProxyRequest->Content << Json;
|
||||
ProxyRequest.Location = caServerRequest.Location;
|
||||
ProxyRequest.CloseConnection = false;
|
||||
ProxyRequest.ContentType = CHTTPRequest::json;
|
||||
ProxyRequest.Content << Json;
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, "POST", URI.c_str());
|
||||
CHTTPRequest::Prepare(ProxyRequest, "POST", URI.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
ProxyRequest.AddHeader("Module-Address", caModuleAddress);
|
||||
|
||||
if (!caOrigin.IsEmpty())
|
||||
pProxyRequest->AddHeader("Origin", caOrigin);
|
||||
ProxyRequest.AddHeader("Origin", caOrigin);
|
||||
|
||||
AConnection->CloseConnection(false);
|
||||
|
||||
@@ -472,8 +472,8 @@ namespace Apostol {
|
||||
void CWebService::DoDeal(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI, const CString &Action) {
|
||||
|
||||
auto pProxy = GetProxy(AConnection);
|
||||
auto pServerRequest = AConnection->Request();
|
||||
auto pProxyRequest = pProxy->Request();
|
||||
const auto &caServerRequest = AConnection->Request();
|
||||
auto &ProxyRequest = pProxy->Request();
|
||||
|
||||
const auto &caModuleAddress = m_Module["address"];
|
||||
const auto &caModuleFee = m_Module["fee"];
|
||||
@@ -482,17 +482,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 = caServerRequest.Headers["host"];
|
||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||
|
||||
const auto &address = GetAddress(pServerRequest);
|
||||
const auto &code = pServerRequest->Params["code"];
|
||||
const auto &address = GetAddress(caServerRequest);
|
||||
const auto &code = caServerRequest.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 = caServerRequest.Params["pgp"];
|
||||
const auto &caServerParam = caServerRequest.Params["server"];
|
||||
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
@@ -508,13 +508,13 @@ namespace Apostol {
|
||||
|
||||
CString sPayload;
|
||||
|
||||
if (!pServerRequest->Content.IsEmpty() && Action != "status") {
|
||||
if (!caServerRequest.Content.IsEmpty() && Action != "status") {
|
||||
|
||||
const auto &ContentType = pServerRequest->Headers.Values(_T("content-type"));
|
||||
const auto &ContentType = caServerRequest.Headers.Values(_T("content-type"));
|
||||
|
||||
if (ContentType.Find("application/x-www-form-urlencoded") == 0) {
|
||||
|
||||
const CStringList &FormData = pServerRequest->FormData;
|
||||
const CStringList &FormData = caServerRequest.FormData;
|
||||
|
||||
const auto &formType = FormData["type"];
|
||||
const auto &formAt = FormData["at"];
|
||||
@@ -605,7 +605,7 @@ namespace Apostol {
|
||||
} else if (ContentType.Find("multipart/form-data") == 0) {
|
||||
|
||||
CFormData FormData;
|
||||
CHTTPRequestParser::ParseFormData(pServerRequest, FormData);
|
||||
CHTTPRequestParser::ParseFormData(caServerRequest, FormData);
|
||||
|
||||
const auto &formType = FormData.Data("type");
|
||||
const auto &formAt = FormData.Data("at");
|
||||
@@ -695,7 +695,7 @@ namespace Apostol {
|
||||
|
||||
} else if (ContentType.Find("application/json") == 0) {
|
||||
|
||||
const CJSON jsonData(pServerRequest->Content);
|
||||
const CJSON jsonData(caServerRequest.Content);
|
||||
|
||||
const auto &formOrder = jsonData["order"].AsString().Lower();
|
||||
const auto &formType = jsonData["type"].AsString();
|
||||
@@ -794,7 +794,7 @@ namespace Apostol {
|
||||
}
|
||||
|
||||
} else {
|
||||
Node = YAML::Load(pServerRequest->Content.c_str());
|
||||
Node = YAML::Load(caServerRequest.Content.c_str());
|
||||
}
|
||||
|
||||
const auto &BTCKeys = caContext.BTCKeys();
|
||||
@@ -871,25 +871,25 @@ namespace Apostol {
|
||||
if (!sPayload.IsEmpty())
|
||||
Json.Object().AddPair("payload", base64_encode(sPayload));
|
||||
|
||||
pProxyRequest->Clear();
|
||||
ProxyRequest.Clear();
|
||||
|
||||
pProxyRequest->Location = pServerRequest->Location;
|
||||
pProxyRequest->CloseConnection = true;
|
||||
pProxyRequest->ContentType = CHTTPRequest::json;
|
||||
pProxyRequest->Content << Json;
|
||||
ProxyRequest.Location = caServerRequest.Location;
|
||||
ProxyRequest.CloseConnection = true;
|
||||
ProxyRequest.ContentType = CHTTPRequest::json;
|
||||
ProxyRequest.Content << Json;
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, "POST", URI.c_str());
|
||||
CHTTPRequest::Prepare(ProxyRequest, "POST", URI.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
ProxyRequest.AddHeader("Module-Address", caModuleAddress);
|
||||
|
||||
if (!caModuleFee.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Fee", caModuleFee);
|
||||
ProxyRequest.AddHeader("Module-Fee", caModuleFee);
|
||||
|
||||
if (!caOrigin.IsEmpty())
|
||||
pProxyRequest->AddHeader("Origin", caOrigin);
|
||||
ProxyRequest.AddHeader("Origin", caOrigin);
|
||||
|
||||
AConnection->TimeOutInterval(30 * 1000);
|
||||
AConnection->UpdateTimeOut(Now());
|
||||
@@ -904,8 +904,8 @@ namespace Apostol {
|
||||
void CWebService::DoProxy(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
||||
|
||||
auto pProxy = GetProxy(AConnection);
|
||||
auto pServerRequest = AConnection->Request();
|
||||
auto pProxyRequest = pProxy->Request();
|
||||
const auto &caServerRequest = AConnection->Request();
|
||||
auto &ProxyRequest = pProxy->Request();
|
||||
|
||||
const auto &caModuleAddress = m_Module["address"];
|
||||
const auto &caModuleFee = m_Module["fee"];
|
||||
@@ -914,18 +914,18 @@ 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 &caContentType = pServerRequest->Headers["content-type"].Lower();
|
||||
const auto &caHost = caServerRequest.Headers["host"];
|
||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
||||
|
||||
const auto &address = GetAddress(pServerRequest);
|
||||
const auto &code = pServerRequest->Params["code"];
|
||||
const auto &address = GetAddress(caServerRequest);
|
||||
const auto &code = caServerRequest.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 = caServerRequest.Params["pgp"];
|
||||
const auto &caServerParam = caServerRequest.Params["server"];
|
||||
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
@@ -937,29 +937,29 @@ namespace Apostol {
|
||||
pProxy->Host() = Location.hostname;
|
||||
pProxy->Port(Location.port == 0 ? BPS_SERVER_PORT : Location.port);
|
||||
|
||||
pProxyRequest->Clear();
|
||||
ProxyRequest.Clear();
|
||||
|
||||
pProxyRequest->Location = pServerRequest->Location;
|
||||
ProxyRequest.Location = caServerRequest.Location;
|
||||
|
||||
if (Method == "POST") {
|
||||
pProxyRequest->ContentType = StringToContentType(caContentType);
|
||||
pProxyRequest->Content = pServerRequest->Content;
|
||||
ProxyRequest.ContentType = StringToContentType(caContentType);
|
||||
ProxyRequest.Content = caServerRequest.Content;
|
||||
}
|
||||
|
||||
pProxyRequest->CloseConnection = true;
|
||||
ProxyRequest.CloseConnection = true;
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, Method.c_str(), URI.c_str(), caContentType.c_str());
|
||||
CHTTPRequest::Prepare(ProxyRequest, Method.c_str(), URI.c_str(), caContentType.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
ProxyRequest.AddHeader("Module-Address", caModuleAddress);
|
||||
|
||||
if (!caModuleFee.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Fee", caModuleFee);
|
||||
ProxyRequest.AddHeader("Module-Fee", caModuleFee);
|
||||
|
||||
if (!caOrigin.IsEmpty())
|
||||
pProxyRequest->AddHeader("Origin", caOrigin);
|
||||
ProxyRequest.AddHeader("Origin", caOrigin);
|
||||
|
||||
AConnection->TimeOutInterval(15 * 1000);
|
||||
AConnection->UpdateTimeOut(Now());
|
||||
@@ -972,15 +972,15 @@ namespace Apostol {
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void CWebService::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);
|
||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||
|
||||
@@ -1002,10 +1002,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 auto &FormData = caRequest.FormData;
|
||||
|
||||
const auto &caClearText = FormData["message"];
|
||||
CheckKeyForNull("message", caClearText.c_str());
|
||||
@@ -1014,7 +1014,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());
|
||||
@@ -1022,7 +1022,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());
|
||||
@@ -1030,7 +1030,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);
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ namespace Apostol {
|
||||
Json.Object().AddPair("message", message);
|
||||
|
||||
AConnection->CloseConnection(true);
|
||||
pReply->Content << Json;
|
||||
Reply.Content << Json;
|
||||
|
||||
AConnection->SendReply(CHTTPReply::ok);
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ namespace Apostol {
|
||||
|
||||
Log()->Notice("[%s] [%s] Trying to fetch a PGP key.", Context.Name().c_str(), Context.URL().Origin().c_str());
|
||||
|
||||
auto OnRequest = [&Context](CHTTPClient *Sender, CHTTPRequest *ARequest) {
|
||||
auto OnRequest = [&Context](CHTTPClient *Sender, CHTTPRequest &Request) {
|
||||
|
||||
const auto &name = Sender->Data()["name"];
|
||||
auto &Keys = Context.PGP();
|
||||
@@ -1058,7 +1058,7 @@ namespace Apostol {
|
||||
index++;
|
||||
}
|
||||
|
||||
ARequest->ContentType = CHTTPRequest::json;
|
||||
Request.ContentType = CHTTPRequest::json;
|
||||
|
||||
if (index < Keys.Count()) {
|
||||
auto &Key = Keys[index];
|
||||
@@ -1066,17 +1066,17 @@ namespace Apostol {
|
||||
Key.StatusTime = Now();
|
||||
}
|
||||
|
||||
ARequest->Content = CString().Format(R"({"type": "pgp", "account": "%s", "code": "%s", "fields": ["code", "data"]})", Context.Name().c_str(), name.c_str());
|
||||
Request.Content = CString().Format(R"({"type": "pgp", "account": "%s", "code": "%s", "fields": ["code", "data"]})", Context.Name().c_str(), name.c_str());
|
||||
|
||||
CHTTPRequest::Prepare(ARequest, "POST", "/api/v1/key/public");
|
||||
CHTTPRequest::Prepare(Request, "POST", "/api/v1/key/public");
|
||||
|
||||
const auto &access_token = Context.Tokens()["access_token"];
|
||||
|
||||
if (!access_token.empty()) {
|
||||
ARequest->AddHeader("Authorization", "Bearer " + access_token);
|
||||
Request.AddHeader("Authorization", "Bearer " + access_token);
|
||||
}
|
||||
|
||||
DebugRequest(ARequest);
|
||||
DebugRequest(Request);
|
||||
};
|
||||
|
||||
auto OnExecute = [this, &Context](CTCPConnection *AConnection) {
|
||||
@@ -1085,15 +1085,15 @@ namespace Apostol {
|
||||
|
||||
if (pConnection != nullptr) {
|
||||
auto pClient = dynamic_cast<CHTTPClient *> (pConnection->Client());
|
||||
auto pReply = pConnection->Reply();
|
||||
const auto &Reply = pConnection->Reply();
|
||||
|
||||
DebugReply(pReply);
|
||||
DebugReply(Reply);
|
||||
|
||||
CString Code;
|
||||
CString Key;
|
||||
|
||||
try {
|
||||
JsonStringToKey(pReply->Content, Code, Key);
|
||||
JsonStringToKey(Reply.Content, Code, Key);
|
||||
|
||||
if (Key.IsEmpty())
|
||||
throw Delphi::Exception::Exception("Not found.");
|
||||
|
||||
Reference in New Issue
Block a user