目前我想让我的indy代理服务器将请求转发给另一个代理服务器。我找到this link并亲自试了一下。但是我的代码没有任何错误消息就行不通,好像我没有做任何改动。我的代码如下所示在C ++ XE2中。
void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{
TIdIOHandlerStack* tempIO = new TIdIOHandlerStack(NULL);
TIdConnectThroughHttpProxy* tempProxy = new TIdConnectThroughHttpProxy(NULL);
tempProxy->Enabled = true;
tempProxy->Host = "localhost";
tempProxy->Port = 8181 ;
tempIO->TransparentProxy = tempProxy;
AContext->OutboundClient->IOHandler = tempIO;
}
答案 0 :(得分:2)
最后我发现我做了一些愚蠢的事。正确的代码应该如下......
void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{
TIdIOHandlerStack* tempIO = new TIdIOHandlerStack(AContext->OutboundClient);
TIdConnectThroughHttpProxy* tempProxy = new TIdConnectThroughHttpProxy(AContext->OutboundClient);
tempProxy->Enabled = true;
tempProxy->Host = "localhost";
tempProxy->Port = 8181 ;
tempIO->TransparentProxy = tempProxy;
AContext->OutboundClient->IOHandler = tempIO;