curl-library
zero-length files
Date: Wed, 12 Nov 2008 17:26:52 +0100
Hi,
handling of zero-length files is a bit suboptimal:
The code in the my_fwrite() function in the commandline tool expects
that the callback can be called with sz * nmemb == 0, but
Curl_client_write() never does that, so 'curl -O http://host/zero-file'
will not create a local file. Further debugging shows that
Curl_client_write() isn't even called when the size is known in advance
(aka Content-Length: 0). I don't know how to fix it yet.
Also this looks like a bug in Curl_client_write():
if(data->req.keepon & KEEP_READ_PAUSE) {
...
newlen = len + data->state.tempwritesize;
...
memcpy(newptr + data->state.tempwritesize, ptr, len);
...
}
if(0 == len)
len = strlen(ptr);
The check for 0 == len should IMO be done first, otherwise we might lose
data.
Michal
Received on 2008-11-12