我想與需要摘要式身份驗證的局域網(http://)服務器進行通信。Indy(德爾福)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 401未經授權作爲IdHttp1.ResponseText從服務器。如果輸入用戶名和密碼,Firefox和Chrome都可以正常連接。
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
我用Google搜索了很多關於這個問題:
我從SVN和Delphi 7
服務器的HTTP頭(192.168.1.10局域網)已經在最新的印10顯然很多人在使用indy身份驗證時遇到麻煩(它是否可以工作?)。
嘗試包含此行'IdHttp1.Request.BasicAuthentication:= False;'。 – TLama