HwT*_*rap 6 delphi indy delphi-2010 idhttp
我正在尝试使用Indy HTTP类进行HTTP身份验证.但由于某些未知原因,我在此行中收到了访问冲突错误: IdHTTP1.Request.Authentication.Username:= Username;
代码延伸是:
IdHTTP1:= TIdHttp.Create(Application);
IdHTTP1.ConnectTimeout:= 10000;
IdHTTP1.Request.Clear;
IdHTTP1.Request.BasicAuthentication:= true;
IdHTTP1.Request.Authentication.Username := Username;
IdHTTP1.Request.Authentication.Password := Password;
try
IdHTTP1.Get(PbxURL);
HttpCode := IdHTTP1.ResponseCode;
except
on E: EIdHTTPProtocolException do
HttpCode := IdHTTP1.ResponseCode;
Run Code Online (Sandbox Code Playgroud)
我正在使用Delphi 2010,并且已经尝试过如下操作: IdHTTP1.Request.Authentication.Username:='admin'; 但没有解决问题......
Ken*_*ite 16
从快速检查看,当真实时,似乎没有IdHTTP.Request.Authentication必要(因此没有创建)Request.BasicAuthentication.你应该使用Request.UserName而Request.Password不是.
IdHTTP1:= TIdHttp.Create(Application);
IdHTTP1.ConnectTimeout:= 10000;
IdHTTP1.Request.Clear;
IdHTTP1.Request.BasicAuthentication:= true;
IdHTTP1.Request.UserName := UserName;
IdHTTP1.Request.Password := Password;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11754 次 |
| 最近记录: |