cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Zero size FTP download doesn't update file

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 16 Apr 2003 11:23:57 +0200 (CEST)

On Tue, 15 Apr 2003, Steve Crawford wrote:

> I have run into the following problem which I have been trying to track
> down in 7.10.4 on Linux 2.4.10-4GB ... i686 (although it seems to occur in
> other versions and platforms I've checked):

Right, I think this is a problem that's been around for ages.

> When I do an ftp download and the file on the server is zero size no
> transfer takes place. If the file does not exist locally it is not created.
> If the file does exist locally it is left untouched.

I agree this makes a strange situation. A download of a zero byte file should
create a zero byte file locally.

> This is my first experience hacking into the curl source code so I'm
> treading lightly but I am currently focusing on the fact that
> Curl_readwrite (transfer.c) does not seem to make the appropriate call to
> Curl_client_write when there is no data in the body.

Yes, we need to allow Curl_client_write() to get called with a zero length
without it doing strlen() to figure out the size, and then call the callback.

But, the problem is likely even before that. In lib/ftp.c we catch the case
of zero-byte downloads in a separate if()-case so we could probably just add
a special call to the Curl_client_write() there with no data and zero size.

> Further info when I figure more out or please write if you know where the
> problem lies.

Currently there is no documentation saying that there can't be any zero-sized
data passed in, but when this is fixed we could make a note in the man page
that it may be called with a zero length in cases where an empty file is
downloaded.

And it would be great if you could add a test case for this to verify that it
works.

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-04-16