Jonathan Wareham
Jonathan Wareham

Reputation: 3399

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?

Upvotes: 13

Views: 1116

Answers (1)

Jonathan Wareham
Jonathan Wareham

Reputation: 3399

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.

Upvotes: 1

Related Questions