How do I forward request to another proxy server u

2019-06-06 14:09发布

currently I want to make my indy proxy server forward the request to another proxy server. I have found this link and made a try by myself. But my code does not work without any error message as if I had made no change. My code is as below in 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;

}

1条回答
相关推荐>>
2楼-- · 2019-06-06 14:49

Finally I found I did something stupid. The correct code should be as follow...

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;
查看更多
登录 后发表回答