Fix forbidden answer.
This commit is contained in:
@@ -85,7 +85,7 @@ namespace Apostol {
|
|||||||
while (index < m_Servers.Count()) {
|
while (index < m_Servers.Count()) {
|
||||||
const auto &caContext = m_Servers[index].Value();
|
const auto &caContext = m_Servers[index].Value();
|
||||||
if (caContext.Status() == Context::csRunning) {
|
if (caContext.Status() == Context::csRunning) {
|
||||||
if (Params == caContext.Name() || Params == caContext.URL().Origin()) {
|
if (Params.IsEmpty() || Params == caContext.Name() || Params == caContext.URL().Origin()) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,11 +99,11 @@ namespace Apostol {
|
|||||||
|
|
||||||
bool CWebService::DoProxyExecute(CTCPConnection *AConnection) {
|
bool CWebService::DoProxyExecute(CTCPConnection *AConnection) {
|
||||||
|
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
||||||
auto pProxy = dynamic_cast<CHTTPProxy *> (pConnection->Client());
|
const auto pProxy = dynamic_cast<CHTTPProxy *> (pConnection->Client());
|
||||||
|
|
||||||
if (Assigned(pProxy) && (pProxy->Connection() != nullptr)) {
|
if (Assigned(pProxy) && pProxy->Connection() != nullptr) {
|
||||||
auto pProxyConnection = pProxy->Connection();
|
const auto pProxyConnection = pProxy->Connection();
|
||||||
const auto &caServerRequest = pProxyConnection->Request();
|
const auto &caServerRequest = pProxyConnection->Request();
|
||||||
auto &ServerReply = pProxyConnection->Reply();
|
auto &ServerReply = pProxyConnection->Reply();
|
||||||
const auto &caProxyReply = pConnection->Reply();
|
const auto &caProxyReply = pConnection->Reply();
|
||||||
@@ -145,9 +145,20 @@ namespace Apostol {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ServerReply.Content = caProxyReply.Content;
|
ServerReply.Content = caProxyReply.Content;
|
||||||
|
|
||||||
if (caProxyReply.Status == CHTTPReply::ok) {
|
if (caProxyReply.Status == CHTTPReply::ok) {
|
||||||
pProxyConnection->SendReply(caProxyReply.Status, nullptr, true);
|
pProxyConnection->SendReply(caProxyReply.Status, nullptr, true);
|
||||||
} else {
|
} else {
|
||||||
|
if (caProxyReply.Status == CHTTPReply::forbidden) {
|
||||||
|
const auto &caServerParam = caServerRequest.Params["server"];
|
||||||
|
const auto index = CurrentContextIndex(caServerParam);
|
||||||
|
|
||||||
|
auto &Context = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||||
|
|
||||||
|
Context.SetCheckDate(0);
|
||||||
|
Context.SetStatus(Context::csInitialized);
|
||||||
|
}
|
||||||
|
|
||||||
pProxyConnection->SendStockReply(caProxyReply.Status, true);
|
pProxyConnection->SendStockReply(caProxyReply.Status, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,8 +171,8 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void CWebService::DoProxyException(CTCPConnection *AConnection, const Delphi::Exception::Exception &E) {
|
void CWebService::DoProxyException(CTCPConnection *AConnection, const Delphi::Exception::Exception &E) {
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection*> (AConnection);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection*> (AConnection);
|
||||||
auto pProxy = dynamic_cast<CHTTPProxy*> (pConnection->Client());
|
const auto pProxy = dynamic_cast<CHTTPProxy*> (pConnection->Client());
|
||||||
|
|
||||||
if (Assigned(pProxy) && (pProxy->Connection() != nullptr)) {
|
if (Assigned(pProxy) && (pProxy->Connection() != nullptr)) {
|
||||||
auto pProxyConnection = pProxy->Connection();
|
auto pProxyConnection = pProxy->Connection();
|
||||||
@@ -209,7 +220,7 @@ namespace Apostol {
|
|||||||
//--------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void CWebService::DoProxyDisconnected(CObject *Sender) {
|
void CWebService::DoProxyDisconnected(CObject *Sender) {
|
||||||
auto pConnection = dynamic_cast<CHTTPClientConnection*> (Sender);
|
const auto pConnection = dynamic_cast<CHTTPClientConnection*> (Sender);
|
||||||
if (pConnection != nullptr) {
|
if (pConnection != nullptr) {
|
||||||
Log()->Message(_T("[%s:%d] Client disconnected."), pConnection->Socket()->Binding()->PeerIP(),
|
Log()->Message(_T("[%s:%d] Client disconnected."), pConnection->Socket()->Binding()->PeerIP(),
|
||||||
pConnection->Socket()->Binding()->PeerPort());
|
pConnection->Socket()->Binding()->PeerPort());
|
||||||
@@ -927,7 +938,7 @@ namespace Apostol {
|
|||||||
|
|
||||||
void CWebService::DoProxy(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
void CWebService::DoProxy(CHTTPServerConnection *AConnection, const CString &Method, const CString &URI) {
|
||||||
|
|
||||||
auto pProxy = GetProxy(AConnection);
|
const auto pProxy = GetProxy(AConnection);
|
||||||
const auto &caServerRequest = AConnection->Request();
|
const auto &caServerRequest = AConnection->Request();
|
||||||
auto &ProxyRequest = pProxy->Request();
|
auto &ProxyRequest = pProxy->Request();
|
||||||
|
|
||||||
@@ -938,7 +949,6 @@ namespace Apostol {
|
|||||||
if (checkFee == -1)
|
if (checkFee == -1)
|
||||||
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
throw ExceptionFrm("Invalid module fee value: %s", caModuleFee.c_str());
|
||||||
|
|
||||||
const auto &caHost = caServerRequest.Headers["host"];
|
|
||||||
const auto &caOrigin = caServerRequest.Headers["origin"];
|
const auto &caOrigin = caServerRequest.Headers["origin"];
|
||||||
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
const auto &caContentType = caServerRequest.Headers["content-type"].Lower();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user