Committing updates.
This commit is contained in:
@@ -436,6 +436,8 @@ namespace Apostol {
|
||||
pProxyRequest->AddHeader("Origin", caOrigin);
|
||||
|
||||
AConnection->CloseConnection(false);
|
||||
|
||||
pProxy->AutoFree(true);
|
||||
pProxy->Active(true);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
@@ -852,6 +854,73 @@ namespace Apostol {
|
||||
|
||||
AConnection->CloseConnection(false);
|
||||
|
||||
pProxy->AutoFree(true);
|
||||
pProxy->Active(true);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
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 &caModuleAddress = m_Module["address"];
|
||||
const auto &caModuleFee = m_Module["fee"];
|
||||
|
||||
const auto checkFee = CheckFee(caModuleFee);
|
||||
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 &address = pServerRequest->Params["address"];
|
||||
const auto &code = pServerRequest->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 &caServer = caServerParam.IsEmpty() ? m_CurrentServer.URL().Origin() : caServerParam;
|
||||
|
||||
CLocation Location(caServer);
|
||||
|
||||
pProxy->Host() = Location.hostname;
|
||||
pProxy->Port(Location.port == 0 ? BPS_SERVER_PORT : Location.port);
|
||||
|
||||
pProxyRequest->Clear();
|
||||
|
||||
pProxyRequest->Location = pServerRequest->Location;
|
||||
pProxyRequest->ContentType = pServerRequest->ContentType;
|
||||
|
||||
if (Method == "POST") {
|
||||
pProxyRequest->Content = pServerRequest->Content;
|
||||
}
|
||||
|
||||
pProxyRequest->CloseConnection = true;
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, Method.c_str(), URI.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + m_CurrentServer.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
|
||||
if (!caModuleFee.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Fee", caModuleFee);
|
||||
|
||||
if (!caOrigin.IsEmpty())
|
||||
pProxyRequest->AddHeader("Origin", caOrigin);
|
||||
|
||||
AConnection->TimeOutInterval(15 * 1000);
|
||||
AConnection->UpdateTimeOut(Now());
|
||||
|
||||
AConnection->CloseConnection(false);
|
||||
|
||||
pProxy->AutoFree(true);
|
||||
pProxy->Active(true);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user