Committing updates.
This commit is contained in:
@@ -106,7 +106,10 @@ namespace Apostol {
|
|||||||
auto pProxyConnection = pProxy->Connection();
|
auto pProxyConnection = pProxy->Connection();
|
||||||
const auto &caServerRequest = pProxyConnection->Request();
|
const auto &caServerRequest = pProxyConnection->Request();
|
||||||
auto &ServerReply = pProxyConnection->Reply();
|
auto &ServerReply = pProxyConnection->Reply();
|
||||||
auto &ProxyReply = pConnection->Reply();
|
const auto &caProxyReply = pConnection->Reply();
|
||||||
|
|
||||||
|
DebugRequest(pConnection->Request());
|
||||||
|
DebugReply(caProxyReply);
|
||||||
|
|
||||||
const auto &caFormat = caServerRequest.Params["payload"];
|
const auto &caFormat = caServerRequest.Params["payload"];
|
||||||
if (!caFormat.IsEmpty()) {
|
if (!caFormat.IsEmpty()) {
|
||||||
@@ -120,14 +123,14 @@ namespace Apostol {
|
|||||||
ServerReply.ContentType = CHTTPReply::text;
|
ServerReply.ContentType = CHTTPReply::text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProxyReply.Status == CHTTPReply::ok) {
|
if (caProxyReply.Status == CHTTPReply::ok) {
|
||||||
if (!ProxyReply.Content.IsEmpty()) {
|
if (!caProxyReply.Content.IsEmpty()) {
|
||||||
const CJSON json(ProxyReply.Content);
|
const CJSON json(caProxyReply.Content);
|
||||||
ServerReply.Content = base64_decode(json["payload"].AsString());
|
ServerReply.Content = base64_decode(json["payload"].AsString());
|
||||||
}
|
}
|
||||||
pProxyConnection->SendReply(ProxyReply.Status, nullptr, true);
|
pProxyConnection->SendReply(caProxyReply.Status, nullptr, true);
|
||||||
} else {
|
} else {
|
||||||
if (ProxyReply.Status == CHTTPReply::forbidden) {
|
if (caProxyReply.Status == CHTTPReply::forbidden) {
|
||||||
const auto &caServerParam = caServerRequest.Params["server"];
|
const auto &caServerParam = caServerRequest.Params["server"];
|
||||||
const auto index = CurrentContextIndex(caServerParam);
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
@@ -137,15 +140,15 @@ namespace Apostol {
|
|||||||
Context.SetStatus(Context::csInitialized);
|
Context.SetStatus(Context::csInitialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerReply.Content = ProxyReply.Content;
|
ServerReply.Content = caProxyReply.Content;
|
||||||
pProxyConnection->SendStockReply(ProxyReply.Status, true);
|
pProxyConnection->SendStockReply(caProxyReply.Status, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ServerReply.Content = ProxyReply.Content;
|
ServerReply.Content = caProxyReply.Content;
|
||||||
if (ProxyReply.Status == CHTTPReply::ok) {
|
if (caProxyReply.Status == CHTTPReply::ok) {
|
||||||
pProxyConnection->SendReply(ProxyReply.Status, nullptr, true);
|
pProxyConnection->SendReply(caProxyReply.Status, nullptr, true);
|
||||||
} else {
|
} else {
|
||||||
pProxyConnection->SendStockReply(ProxyReply.Status, true);
|
pProxyConnection->SendStockReply(caProxyReply.Status, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,11 +263,6 @@ namespace Apostol {
|
|||||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||||
const auto &caServer = caContext.URL().Origin();
|
const auto &caServer = caContext.URL().Origin();
|
||||||
|
|
||||||
CLocation Location(caServer);
|
|
||||||
|
|
||||||
pProxy->Host() = Location.hostname;
|
|
||||||
pProxy->Port(Location.port == 0 ? BPS_SERVER_PORT : Location.port);
|
|
||||||
|
|
||||||
CStringList caClearText;
|
CStringList caClearText;
|
||||||
CString sPayload;
|
CString sPayload;
|
||||||
|
|
||||||
@@ -445,15 +443,22 @@ namespace Apostol {
|
|||||||
if (!sPayload.IsEmpty())
|
if (!sPayload.IsEmpty())
|
||||||
Json.Object().AddPair("payload", base64_encode(sPayload));
|
Json.Object().AddPair("payload", base64_encode(sPayload));
|
||||||
|
|
||||||
|
CLocation Location(caServer);
|
||||||
|
|
||||||
|
pProxy->Host() = Location.hostname;
|
||||||
|
pProxy->Port(Location.port == 0 ? BPS_SERVER_PORT : Location.port);
|
||||||
|
|
||||||
ProxyRequest.Clear();
|
ProxyRequest.Clear();
|
||||||
|
|
||||||
ProxyRequest.Location = caServerRequest.Location;
|
ProxyRequest.Location = Location.hostname + caServerRequest.Location.pathname + caServerRequest.Location.search;
|
||||||
ProxyRequest.CloseConnection = false;
|
ProxyRequest.CloseConnection = false;
|
||||||
ProxyRequest.ContentType = CHTTPRequest::json;
|
ProxyRequest.ContentType = CHTTPRequest::json;
|
||||||
ProxyRequest.Content << Json;
|
ProxyRequest.Content << Json;
|
||||||
|
|
||||||
CHTTPRequest::Prepare(ProxyRequest, "POST", URI.c_str());
|
CHTTPRequest::Prepare(ProxyRequest, "POST", URI.c_str());
|
||||||
|
|
||||||
|
ProxyRequest.Headers.Values("Host", ProxyRequest.Location.Host());
|
||||||
|
|
||||||
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||||
|
|
||||||
if (!caModuleAddress.IsEmpty())
|
if (!caModuleAddress.IsEmpty())
|
||||||
@@ -465,6 +470,7 @@ namespace Apostol {
|
|||||||
AConnection->CloseConnection(false);
|
AConnection->CloseConnection(false);
|
||||||
|
|
||||||
pProxy->AutoFree(true);
|
pProxy->AutoFree(true);
|
||||||
|
pProxy->UsedSSL(Location.protocol == HTTPS_PREFIX);
|
||||||
pProxy->Active(true);
|
pProxy->Active(true);
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
@@ -499,11 +505,6 @@ namespace Apostol {
|
|||||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||||
const auto &caServer = caContext.URL().Origin();
|
const auto &caServer = caContext.URL().Origin();
|
||||||
|
|
||||||
CLocation Location(caServer);
|
|
||||||
|
|
||||||
pProxy->Host() = Location.hostname;
|
|
||||||
pProxy->Port(Location.port == 0 ? BPS_SERVER_PORT : Location.port);
|
|
||||||
|
|
||||||
YAML::Node Node;
|
YAML::Node Node;
|
||||||
|
|
||||||
CString sPayload;
|
CString sPayload;
|
||||||
@@ -871,15 +872,22 @@ namespace Apostol {
|
|||||||
if (!sPayload.IsEmpty())
|
if (!sPayload.IsEmpty())
|
||||||
Json.Object().AddPair("payload", base64_encode(sPayload));
|
Json.Object().AddPair("payload", base64_encode(sPayload));
|
||||||
|
|
||||||
|
CLocation Location(caServer);
|
||||||
|
|
||||||
|
pProxy->Host() = Location.hostname;
|
||||||
|
pProxy->Port(Location.port == 0 ? BPS_SERVER_PORT : Location.port);
|
||||||
|
|
||||||
ProxyRequest.Clear();
|
ProxyRequest.Clear();
|
||||||
|
|
||||||
ProxyRequest.Location = caServerRequest.Location;
|
ProxyRequest.Location = Location.hostname + caServerRequest.Location.pathname + caServerRequest.Location.search;
|
||||||
ProxyRequest.CloseConnection = true;
|
ProxyRequest.CloseConnection = true;
|
||||||
ProxyRequest.ContentType = CHTTPRequest::json;
|
ProxyRequest.ContentType = CHTTPRequest::json;
|
||||||
ProxyRequest.Content << Json;
|
ProxyRequest.Content << Json;
|
||||||
|
|
||||||
CHTTPRequest::Prepare(ProxyRequest, "POST", URI.c_str());
|
CHTTPRequest::Prepare(ProxyRequest, "POST", URI.c_str());
|
||||||
|
|
||||||
|
ProxyRequest.Headers.Values("Host", ProxyRequest.Location.Host());
|
||||||
|
|
||||||
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
ProxyRequest.AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||||
|
|
||||||
if (!caModuleAddress.IsEmpty())
|
if (!caModuleAddress.IsEmpty())
|
||||||
@@ -897,6 +905,7 @@ namespace Apostol {
|
|||||||
AConnection->CloseConnection(false);
|
AConnection->CloseConnection(false);
|
||||||
|
|
||||||
pProxy->AutoFree(true);
|
pProxy->AutoFree(true);
|
||||||
|
pProxy->UsedSSL(Location.protocol == HTTPS_PREFIX);
|
||||||
pProxy->Active(true);
|
pProxy->Active(true);
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
@@ -939,7 +948,8 @@ namespace Apostol {
|
|||||||
|
|
||||||
ProxyRequest.Clear();
|
ProxyRequest.Clear();
|
||||||
|
|
||||||
ProxyRequest.Location = caServerRequest.Location;
|
ProxyRequest.Location = Location.hostname + caServerRequest.Location.pathname + caServerRequest.Location.search;
|
||||||
|
ProxyRequest.Headers.Values("Host", ProxyRequest.Location.Host());
|
||||||
|
|
||||||
if (Method == "POST") {
|
if (Method == "POST") {
|
||||||
ProxyRequest.ContentType = StringToContentType(caContentType);
|
ProxyRequest.ContentType = StringToContentType(caContentType);
|
||||||
@@ -967,6 +977,7 @@ namespace Apostol {
|
|||||||
AConnection->CloseConnection(false);
|
AConnection->CloseConnection(false);
|
||||||
|
|
||||||
pProxy->AutoFree(true);
|
pProxy->AutoFree(true);
|
||||||
|
pProxy->UsedSSL(Location.protocol == HTTPS_PREFIX);
|
||||||
pProxy->Active(true);
|
pProxy->Active(true);
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user