cURL / Mailing Lists / curl-library / Single Mail

curl-library

Reusing handle -> no headers

From: Tro <troworld_at_gmail.com>
Date: Thu, 14 Jun 2007 13:10:46 -0400

Hi.

I'm using libcurl-7.16.2 compiled as a dll (libcurl-4.dll) with SSL support on
Windows 2000 inside an MFC app. I'm dealing with a vsftpd FTP server I'm
administering.

My usage scenario is this:

1. List files in a directory. Do something with the file names.
2. In a loop for a set of filenames
2.1. Reuse the handle from 1. Set the URL, header function/data. Use the
header function callback to figure out the content-length of the remote file
I'm about to download using sscanf(..., "Content-Length: %ld\n", ...).
2.2 If the file needs resuming, do so. Otherwise, download the file from
start.

Before 2.1 I enable the header function and set NOBODY to TRUE and before 2.2
I disable the header function and set NOBODY to FALSE.

I'm reusing the handle in all steps. This is what occurs:
* 1 completes successfully.
* 2.1 works for the first file. That is, the header callback is used and I'm
able to find out the Content-Length of the remote file.
* 2.2 works ok, downloads the file.
* 2.1 doesn't quite work for subsequent files. The header callback is never
called, the server does not show any commands/activity in the logs.
curl_easy_perform() completes way too quickly.
* 2.2 again works okay, but downloads the entire file because I wasn't able to
figure out Content-Length from the previous 2.1.

Why does this happen?

If I set CURLOPT_FRESH_CONNECT or CURLOPT_FORBID_REUSE, libcurl acts as
expected: reconnects to the server, fetches the size of the file,
downloads/resumes it.

Thanks for any help.
Received on 2007-06-14