I am trying to access the update.txt file on my website using the compiled DelphiXE program and the IdHTTP component.
The code I use is as follows:
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;
This results in an error: HTTP1.1 / 403 Forbidden
The IdHTTP component is configured with the following properties.
HandleRedirects := true; HTTPOptions [hoForceEncodeParams]; ProtocolVersion := pv1_1; Request.UserAgent := Mozilla/5.0 (compatible; Test)
If I enter the URL in IE browser, it returns the file without errors, but when I access my program, I get an error. Any pointers would be appreciated. .htaccess is correct for the site. The rights to the file are indicated on the website: 0644.
Do I need to set any other properties for the IdHTTP component. I have only this component in the form. I need something else.
The updateinfo.txt file simply contains the text in quotation marks: "18.3.5,2011 / 12/17"
I just used "test" here instead of my actual name and program url.
Relations Adrian
Adrian wreyford
source share