CyprUS
CyprUS

Reputation: 4239

How to implement download resume facility with ICS THttpCli in Delphi 7?

I wanted to implement a download manager with HttpCli with download resumption facility as is present in FtpClient ( ICS Components) . In FtpClient , this is achieved using RestGetAsync . I came across two properties ContentRangeBegin and ContentRangeEnd .

I had set ContentRangeBegin = 192 and ContentRangeEnd to 500 bytes. I set the URL to "http://www.google.com'. I expected only ContentRangeEnd - ContentRangeBegin to be downloaded . But the full file was downloaded .

I set the RcvdStream as HttpCli1.RcvdStream := TFileStream.Create('c:\a.txt',fmCreate); // setting to OpenWrite mode only appends the full file to the existing file.

a.txt was present in C:\ drive with size of 197 bytes.

What more needs to be done ?

Thanks in advance

Upvotes: 0

Views: 1149

Answers (1)

CyprUS
CyprUS

Reputation: 4239

The code is fine. I changed the URL to `www.overbyte.be' and the file was downloaded partially. Here is my code which can be helpful to others .

   HttpCli2.URL := 'http://www.overbyte.be';
   HttpCli2.Proxy := 'xxxx';
   HttpCli2.ProxyPort := 'xxxx';

   Try
      HttpCli2.RcvdStream := TFileStream.Create('E:\sanj\t1.txt',fmCreate);

   Except 

   End;
    HttpCli2.ContentRangeBegin := '100';

   HttpCli2.ContentRangeEnd   := '232';
   Try
     HttpCli2.Get;
     httpCli1.RcvdStream.Free;
    httpCli1.RcvdStream := nil;
    ShowMessage('Status code  =' + IntToStr(HttpCli2.StatusCode) + ' , reason -> '   +HttpCli2.ReasonPhrase);


   Except
   End;

Upvotes: 1

Related Questions