Re: Resuming downloads; remote filesize
Date: Sat, 1 Sep 2001 11:16:50 +0200 (MET DST)
On Fri, 31 Aug 2001, Glenn McGrath wrote:
> If i chop off the end of the local file and resume downloading, it does
> resume the download and works perfectly.
> However i still have a small problem when i resume an already complete
> download, the download fails with file not found.
When we're talking about HTTP resumed transfers (as opposed to FTP ones),
libcurl will set the 'Range:' header in the request to the remote server. It
then pretty much expect the server to do the rest of the work.
The server will deal with the Range header according to the HTTP 1.1 specs.
Let me quote from RFC2616, section 10.4.17, regarding error code 416 (which I
assume is the one you get):
A server SHOULD return a response with this status code if a request
included a Range request-header field (section 14.35), and none of
the range-specifier values in this field overlap the current extent
of the selected resource, and the request did not include an If-Range
request-header field. (For byte-ranges, this means that the first-
byte-pos of all of the byte-range-spec values were greater than the
current length of the selected resource.)
It is also spelled out in section 14.34.2:
If the byte-range-set is unsatisfiable, the server SHOULD return a
response with a status of 416 (Requested range not satisfiable).
So, in the eyes of the HTTP server, asking for a range that is beyond the
actual file size, is an error.
One way of dealing with this, would probably be to always resume one (or
more) bytes extra.
-- Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/Received on 2001-09-01