1

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;

}
TylerH
  • 20,799
  • 66
  • 75
  • 101
Willy
  • 1,828
  • 16
  • 41

1 Answers1

2

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;
Willy
  • 1,828
  • 16
  • 41