delphi7 indy idhttp控件文件续传求助

palsword 2010-11-12 05:12:39
下载代码如下,文件从头开始下载一切正常,速度很快。即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;
...全文
186 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bdmh 2010-11-15
  • 打赏
  • 举报
回复
那你跟踪一下是哪一步慢,是Get的时间满了吗
palsword 2010-11-15
  • 打赏
  • 举报
回复
是的。我试过这段代码。更改contentrangestart为0,速度就很正常。
奇怪的说
palsword 2010-11-15
  • 打赏
  • 举报
回复
是idhttp的work事件,间隔时间变的很久。
bdmh 2010-11-12
  • 打赏
  • 举报
回复
确认是ContentRangeStart不同引起的吗

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧