下载代码如下,文件从头开始下载一切正常,速度很快。即idhtp1.Request.ContentRangeStart为0
如果续传的话,即idhtp1.Request.ContentRangeStart>0, 下载速度变的非常慢,不知道怎么解决。
请大侠指点,谢谢//下载文件
procedure TProgForm.DownFile(fileUrl: string);
var
  fileName:string;
  tStream: TFileStream;
begin
  fileName:='setup' + IntToStr(mForm.lpNode.iSoft_Id) + '.exe'; //从下载路径中获取文件名  if FileExists(fileName) then            //如果文件已经存在
    tStream := TFileStream.Create(fileName, fmOpenWrite)
  else
    tStream := TFileStream.Create(fileName, fmCreate);  {if not  FileExists(fileName) then      //初次下载
  begin
    idhtp1.Request.ContentRangeStart:=0; //从指定文件偏移处请求下载文件
    startIndex:=0;
  end
  else begin                              //续传}
  try
    startIndex:=tStream.Size-1;
    if startIndex < 0 then startIndex:=0;
    idhtp1.Request.ContentRangeStart := startIndex;
    tStream.Position := startIndex  ;      //移动到最后继续下载
    idhtp1.HandleRedirects := true;
    idhtp1.Head(fileUrl);                //发送HEAD请求
 // end;  
    self.idhtp1.Get(fileUrl,tStream);
  except
  end;  tStream.Free;
end;