cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl putting empty file on Mac OS X

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 18 Dec 2003 17:14:41 +0100 (CET)

On Wed, 17 Dec 2003, Josh Anon wrote:

> > Now, this is an interesting difference. There's no Content-Length:
> > header here in the log from your program! It should be.

> ok, should i add this manually?

No, libcurl should add it itself when you provide a non-zero INFILESIZE.

> > I doubt this works on any platform. ftell() returns the "seek position" in
> > the file so far, and this will be 0 in this case. Setting a zero byte file
> > size is not a good idea here!

> yeah, this was the last thing I tried before emailing (saw it in some 3rd
> party curl example), and I forgot to switch back to the struct stat st_size
> method used in the example. Using st_size put an empty file, too, even
> though the size was nonzero.

Try typecasting the st_size to a (long) when you set it with INFILESIZE, as
it is of type off_t on multiple platforms:

 curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)struct.st_size);

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
   [[ Do not send mails to this email address. They won't reach me. ]]
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-18