Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Seattle DataSnap Client - Proxy server settings not working

I'm connecting to a DataSnap server using a generated DS client proxy class, via TDSRESTConnection. The connection works fine and I can call the server methods. I now want to connect through a proxy server, so I am setting the properties on the TDSRESTConnection object, but I can see that nothing is being sent via the proxy server, as if the properties are being ignored. My code is as follows :

var
  myDS: TServerMethodsClient;
begin
  DSRESTConnectionCfg.ProxyHost := 'localhost';
  DSRESTConnectionCfg.ProxyPort := 8888;
  myDS := TServerMethodsClient.Create(DSRESTConnectionCfg, False);
  myDS.ServerMethodOne();
  myDS.Free;
end;

I have also tried setting :

  DSRESTConnectionCfg.HTTP.ProxyParams.ProxyServer := 'localhost';
  DSRESTConnectionCfg.HTTP.ProxyParams.ProxyPort := 8888;

Both have no effect. However I know this code is working in the previous version of Delphi I was using which is XE6. Problem seems to be in the move to XE10.

Can anybody shed any light on this?

like image 263
Jonathan Wareham Avatar asked Mar 01 '26 05:03

Jonathan Wareham


1 Answers

Problem is due to a bug in the Datasnap.DSHTTPClient.pas unit in the TDSHTTP.PrepareRequest procedure :

procedure TDSHTTP.PrepareRequest(const ARequest: IHTTPRequest);
var
  LIPRequest: TIPHTTPRequest;
  I: Integer;
  Lprox: TProxySettings;
begin
  if FProxyConnectionInfo <> nil then
  begin
    Lprox := TIPProxyConnectionInfo(FProxyConnectionInfo).FProxySettings;
    //if Lprox.UserName <> emptystr then  // <-- Comment this line out
      FHTTPClient.ProxySettings := TProxySettings.Create(Lprox.Host, Lprox.Port, Lprox.UserName, Lprox.password, Lprox.Scheme);
  end;

The code is only applying the proxy server settings if a proxy username is specified, whereas it should always apply the settings regardless.

like image 131
Jonathan Wareham Avatar answered Mar 04 '26 01:03

Jonathan Wareham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!