EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Content-range example for HTTP client for partial download of a file..

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#24133
Posted: 03/17/2013 22:15:20
by Tim Koscielski (Standard support level)
Joined: 03/17/2013
Posts: 6

I have been looking to use TElHTTPSClient1 and Content-range to download partial files from an Apache server. Using the ContentRangeStart, ContentRangeEnd, and ContentRangeFullSize fields, when I to to do a get to a TFileStream in the OnData event, I continue to receive the entire file.

Do you have any examples that show downloading a partial file or HTML request?

Thanks.
#24134
Posted: 03/18/2013 00:47:22
by Eugene Mayevski (EldoS Corp.)

ContentRange* properties are for posting of data. Setting them for request doesn't do anything.

You need Range header which you need to add yourself as a custom header in OnPreparedHeaders event handler. The header is described in section 14.35 of RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt).

The reason is that complex ranges can be specified and as partial download is a rare operation (in a total use of HTTP retrieval), we didn't make the interface for managing ranges for the request.


Sincerely yours
Eugene Mayevski
#24139
Posted: 03/18/2013 09:31:34
by Tim Koscielski (Standard support level)
Joined: 03/17/2013
Posts: 6

Once I turned of UseCompression on the object, I then realized better what those properties were for by reviewing the headers.

I did solve the problem for adding my own headers with the correct range used for partial downloads. Below is the range sample that downloads everything after the first 100,000 bytes. When I added this to the Header in the event OnPreparedHeaders, everything worked as expected.

Code
Range: bytes=100001-


Thanks.

Reply

Statistics

Topic viewed 1178 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!