相关疑难解决方法(0)

IdHTTP.get返回HTTP1.1/403禁止

我正在尝试使用DelphiXE编译程序和IdHTTP组件访问我网站上的update.txt文件.

我正在使用的代码如下:

procedure TFormAbout.SpeedButtonUpdateClick(Sender: TObject);

function CheckUpdates: String;
var lIdHttp: TIdHTTP;
begin
  lIdHttp := TIdHTTP.Create(nil);
  result := lIdHttp.Get('http://www.test.com/test_down_load/update.txt');
end;

var
sWebVersion: String;
sVersionList: TStringList;

begin
try
  sWebVersion := Checkupdates;
except
  on E: Exception do
  begin 
    ShowMEssage(E.ErrorMessage);
    MessageDlg('An Error occured checking for an update.',mtError,[mbOK],0);
  end;
end;
if sWebVersion <> '' then
  begin
    sVersionList.CommaText := sWebVersion;
    ShowMessage('Version: ' + sVersionList[0] + ' - ' + 'Date: ' + sVersionList[1]);
  end;
end;
Run Code Online (Sandbox Code Playgroud)

但是会导致错误:HTTP1.1/403禁止

已使用以下属性设置IdHTTP组件.

HandleRedirects := true;
HTTPOptions [hoForceEncodeParams];
ProtocolVersion := pv1_1;
Request.UserAgent …
Run Code Online (Sandbox Code Playgroud)

delphi indy10 idhttp

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

delphi ×1

idhttp ×1

indy10 ×1