Author Topic: idHTTPProxyServer through another Http proxy  (Read 1340 times)


  • New member
  • *
  • Posts: 33
idHTTPProxyServer through another Http proxy
« on: April 05, 2018, 10:44:05 am »
Good day.

It is not possible to redirect requests to another proxy server.

Code: Pascal  [Select]
  1. procedure TfrmMain.IdHTTPProxyServerHTTPBeforeCommand(AContext: TIdHTTPProxyServerContext);
  2. var
  3. tProxy: TIdCustomTransparentProxy;
  4. begin
  5. tProxy:=TIdCustomTransparentProxy.Create(AContext.Connection);
  6. tProxy.Host:='';
  7. tProxy.Port:=8888;
  8. tProxy.Enabled:=true;
  9. AContext.Connection.Socket.TransparentProxy:=tProxy;
  10. end;

I need through http (get, post).
I know how to redirect requests using the "Connect" method, but it does not work with all proxy servers.

I need your help.  :-[
Sorry for my english, google translation!

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 533
    • Lebeau Software
Re: idHTTPProxyServer through another Http proxy
« Reply #1 on: April 10, 2018, 07:41:42 pm »
It doesn't work because you are setting it up the wrong way.

TIdCustomTransparentProxy is an abstract base class, do not instantiate it directly.  You need to use a descendant instead (TIdSocksInfo for a SOCKS proxy, TIdConnectThroughHttpProxy for an HTTP proxy, etc).

But more importantly, you are attaching the TransparentProxy to the wrong TCP connection.  'AContext.Connection' is the existing established TCP connection with the client that connected to TIdHTTPProxyServer.  To pass that client's traffic with the target server through another proxy, you need to attach the TransparentProxy to 'AContext.OutboundClient' instead.

Try something more like this:

Code: [Select]
procedure TfrmMain.IdHTTPProxyServerHTTPBeforeCommand(AContext: TIdHTTPProxyServerContext);
  tProxy: TIdConnectThroughHttpProxy;
  tProxy := TIdConnectThroughHttpProxy.Create(AContext.OutboundClient.IOHandler);
  tProxy.Host := '';
  tProxy.Port := 8888;
  tProxy.Enabled := true;
  AContext.OutboundClient.Socket.TransparentProxy := tProxy;
« Last Edit: April 10, 2018, 07:44:33 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)