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

青春壹個敷衍的年華 提交于 2020-01-01 18:16:13

问题


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!


回答1:


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;



回答2:


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-';


来源:https://stackoverflow.com/questions/7202462/delphi-xe-idhttp-request-range-a-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!