HTTP Get and HTTP/1.1 403 Forbidden

Giganews Newsgroups
Subject: HTTP Get and HTTP/1.1 403 Forbidden
Posted by:  ClĂ©ment_Doss
Date: Sat, 16 Feb 2008

Hi,

I am using Indy 10.2.3 in a project. I am doing a unit test of an http.get routine
and ii is failing sometimes.

For testing purposes I am downloading 2Mbyte from the internet.
The routine does essentially the basics:
  1) Connects
  2) Do the Get
  3) disconnects

I run the test 10 times. +/- 4 times I get a "HTTP/1.1 403 Forbidden".

Sometimes, if I close the application and open it again, the error HTTP/1.1 403
Forbidden pops at the first try.
I connect/disconnect to/from the same server 10 times.

for i:= 0 to 9 do
    Bla( /Parameterlist/ );

Well.. of course there's no forbidden access. I just guess I am messing something.
The final project will download up to 25 files from up to 5 different urls.
Any ideias?

TIA,
Clément

Code :
function Bla( /ParameterList/ ) : Boolean;
begin
    aErrMsg := '';
    FHTTP.Connect(aHost,aPort);
    if FHTTP.Connected then begin
      LocalStream := TFileStream.Create( aLocalFile, fmCreate or fmOpenWrite  );
      try
        try
          FHTTP.Get( aBaseURL + aRemoteFile, LocalStream );
        except
          on E:Exception do
              aErrMsg := e.message;
        end;
      finally
        LocalStream.Free;
        FHTTP.Disconnect;
      end;
    end;
    Result := aErrMsg<>'';
end;

Replies