Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest Delphi Seattle DataSnap客户端-代理服务器设置不工作_Rest_Delphi_Proxy_Datasnap - Fatal编程技术网

Rest Delphi Seattle DataSnap客户端-代理服务器设置不工作

Rest Delphi Seattle DataSnap客户端-代理服务器设置不工作,rest,delphi,proxy,datasnap,Rest,Delphi,Proxy,Datasnap,我正在通过TDSRESTConnection使用生成的DS客户端代理类连接到DataSnap服务器。连接工作正常,我可以调用服务器方法。现在我想通过代理服务器进行连接,因此我正在设置TDSRESTConnection对象的属性,但是我可以看到没有通过代理服务器发送任何内容,就好像忽略了属性一样。我的代码如下: var myDS: TServerMethodsClient; begin DSRESTConnectionCfg.ProxyHost := 'localhost'; DSRE

我正在通过TDSRESTConnection使用生成的DS客户端代理类连接到DataSnap服务器。连接工作正常,我可以调用服务器方法。现在我想通过代理服务器进行连接,因此我正在设置TDSRESTConnection对象的属性,但是我可以看到没有通过代理服务器发送任何内容,就好像忽略了属性一样。我的代码如下:

var
  myDS: TServerMethodsClient;
begin
  DSRESTConnectionCfg.ProxyHost := 'localhost';
  DSRESTConnectionCfg.ProxyPort := 8888;
  myDS := TServerMethodsClient.Create(DSRESTConnectionCfg, False);
  myDS.ServerMethodOne();
  myDS.Free;
end;
我还尝试设置:

  DSRESTConnectionCfg.HTTP.ProxyParams.ProxyServer := 'localhost';
  DSRESTConnectionCfg.HTTP.ProxyParams.ProxyPort := 8888;
两者都没有效果。然而,我知道这段代码在我使用的Delphi的前一个版本XE6中工作。问题似乎出在XE10上


有人能解释一下吗?

问题是由于TDSHTTP.PrepareRequest过程中的Datasnap.DSHTTPClient.pas单元中有一个bug造成的:

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;
程序TDSHTTP.PrepareRequest(const areRequest:IHTTPreRequest);
变量
LIPRequest:TIPHTTPRequest;
I:整数;
Lprox:tproxy设置;
开始
如果FProxyConnectionInfo为零,则
开始
Lprox:=TIPProxyConnectionInfo(FProxyConnectionInfo).FProxySettings;

//如果Lprox.UserName emptystr,那么//XE6版本是否与您在同一台机器上工作您无法使用“XE10”版本?顺便说一句,没有XE10,XE8后版本是西雅图、柏林和东京-您使用的是哪一个?嗨,是的,在同一台电脑上XE6可以正常工作。对不起,我使用的是Delphi Seattle。更改属性后您需要重设或重新打开连接吗?嗨,不,在创建TServerMethodsClient之后,我也尝试过设置属性,但没有什么不同。对于通过HTTP.ProxyParams设置这些属性的方法,我发现了一条提示,您是否尝试过使用它而不是“localhost”?