1

目前我想让我的 indy 代理服务器将请求转发到另一个代理服务器。我找到了这个链接并自己尝试了一下。但是我的代码在没有任何错误消息的情况下无法运行,就好像我没有进行任何更改一样。我的代码在 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;

}
4

1 回答 1

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;
于 2012-07-23T04:04:10.600 回答