Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.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
Indy(Delphi)Http客户端和摘要身份验证_Delphi_Http_Delphi 7_Indy_Indy10 - Fatal编程技术网

Indy(Delphi)Http客户端和摘要身份验证

Indy(Delphi)Http客户端和摘要身份验证,delphi,http,delphi-7,indy,indy10,Delphi,Http,Delphi 7,Indy,Indy10,我正在尝试与需要摘要身份验证的LAN(http://)服务器通信 uses IdHttp, IdAuthenticationDigest; ... begin IdHttp1 := TIdHttp.Create(nil); try IdHttp1.Request.Username := 'xxx'; IdHttp1.Request.Password := 'xxx'; Result := IdHttp1.Get(URL) finally idHt

我正在尝试与需要摘要身份验证的LAN(http://)服务器通信

uses IdHttp, IdAuthenticationDigest;

...

begin
  IdHttp1 := TIdHttp.Create(nil);
  try
    IdHttp1.Request.Username := 'xxx';
    IdHttp1.Request.Password := 'xxx';

    Result := IdHttp1.Get(URL)
  finally
    idHttp1.Free;
  end;
end; 
不幸的是,我从服务器上得到一个未经授权的HTTP/1.0作为IdHttp1.ResponseText。如果我输入用户名和密码,Firefox和Chrome都可以正常连接

我从SVN和Delphi 7获得了最新的Indy 10

服务器的http标头(局域网上为192.168.1.10):


我在谷歌上搜索了很多关于这个问题的信息,显然很多人在indy身份验证方面遇到了问题(它能工作吗?)

您需要在
TIdHTTP.HTTPOptions
属性中启用
hoInProcessAuth
标志。默认情况下,它处于禁用状态。如果没有该标志,
TIdHTTP.Get()
将不会发送第二个HTTP请求,指定摘要凭据以响应服务器的401响应。它将简单地退出,并希望您处理401响应,并根据需要自己发送一个新请求。

尝试包括此行
IdHttp1.request.BasicAuthentication:=False
Connecting...
Resolving hostname dm7020hd.
Connecting to 192.168.1.10.
Connected.
Server: webserver/1.0
Date: Thu, 31 Jan 2013 11:28:32 GMT
WWW-Authenticate: Digest algorithm="MD5", realm="Forbidden", qop="auth", opaque="7edfc2c756ad1f795651f15f88c32b25", nonce="d2ef913b753b3b6ad8878b34b93cfc5a"
Content-Type: text/html
Cache-Control: no-store, no-cache, must-revalidate
Expires: Sat, 10 Jan 2000 05:00:00 GMT
Content-Length: 15
Last-Modified: Thu, 31 Jan 2013 11:28:32 GMT
ETag: "753868328"
Connection: close
Disconnected