Delphi XE: idHttp & Request.Range, a bug?

2019-04-14 11:59发布

I have Delphi XE. I try to set Request.Range of idHttp but I cannot do this. Delphi doesn't allow me to do this neither at design time nor at run time.

E.g. I set '6000-' in a design time -> a property gets empty all time.

I do (in a thread):

Downloader.Request.Range:=(IntToStr(DFileStream.Position) + '-');
synchronize(procedure begin showmessage(Downloader.Request.Range) end); 

showmessage(Downloader.Request.Range) shows me nothing (an empty string).

I checked a request in HTTPAnalyzer -> my program doesn't send a range.

A checked this behavior in Delphi 2010 - all is normal. I set a range in a design/real time. A result is fine in the both cases.

Does anybody have ideas?

Is this a bug or what?

Thanks!

2条回答
唯我独甜
2楼-- · 2019-04-14 12:16

Read this https://forums.embarcadero.com/thread.jspa?messageID=335670

How to set a range in Delphi XE:

idhttp1.Request.Ranges.Add.StartPos:=6000;

It's the same as

idHttp1.Request.Range:='6000-';
查看更多
手持菜刀,她持情操
3楼-- · 2019-04-14 12:26

The Range property is deprecated instead you must use the the Ranges property.

Check this sample

uses
  IdHTTPHeaderInfo; 

var
  Range: TIdEntityRange;
begin
    Range := FHttp.Request.Ranges.Add;
    Range.StartPos := FRangeFrom;
    Range.EndPos := FRangeTo;
    FHttp.Get(FURL, FileStream);
end;
查看更多
登录 后发表回答