cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Resuming downloads; remote filesize

From: Glenn McGrath <bug1_at_optushome.com.au>
Date: Fri, 31 Aug 2001 23:01:53 +1000

On Thu, 30 Aug 2001 08:23:55 +0200 (MET DST)
"Daniel Stenberg" <daniel_at_haxx.se> wrote:

>
> I'm not sure I understand, can you show us a little example of what
options
> your using, what it reports back and possibly a verbose-dump?
>

Resume is mostly working now, although i realise i should be checking some
timestamps chich i shouldnt be hard.

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.

The following is a summery of my code and some output.

        curl = curl_easy_init();

        res = curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
        res = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        <determine url>
        res = curl_easy_setopt(curl, CURLOPT_URL, full_url);
        < make sure path for download target exists >
        < open file (out_stream) in append mode >
        res = curl_easy_setopt(curl, CURLOPT_FILE, out_stream);
        res = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
        res = curl_easy_setopt(curl, CURLOPT_RESUME_FROM, local_file_length);
        /* Start the actual transfer */
        res = curl_easy_perform(curl);
        if (res == 0) {
                local_files[local_num]->flag = RETR_DONE;
        } else {
                local_files[local_num]->flag = RETR_FAILED;
                printf("retreval (might have) failed for\t%s, %s\n", full_url,
error_buffer);
        }
        <cleanup>

retrieving
http://ftp.au.debian.org/pub/debian/dists/unstable/main/source/Sources.gz
* Connected to karl.planetmirror.com (203.16.234.20)
> GET /pub/debian/dists/unstable/main/source/Sources.gz HTTP/1.1
Range: bytes=616857-
Host: ftp.au.debian.org
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

retreval (might have) failed for
http://ftp.au.debian.org/pub/debian/dists/unstable/main/source/Sources.gz,
The requested file was not found
* Closing live connection (#0)

Thanks

Glenn
Received on 2001-08-31