Haxx ad

curl's project page on


cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

CURLOPT_WRITEDATA append vs overwrite

From: Ganesh Ragavan <>
Date: Thu, 5 Jun 2008 12:18:01 -0700

Hi All,

I am using curl_easy_perform(curl_desc) to fetch bytes of size say 1000
bytes from the server and writing the output to a file. Following is my

1. After 500 bytes are read, the server goes down
2. curl_easy_perform returns error
3. The output file now contains 500 bytes.
4. I am invoking curl_easy_perform(curl_desc) again in a loop.
5. When the server comes back up, curl_easy_perform(curl_desc) reads 1000
bytes and appends it to the output file.
6. The ouput file is now of size 1500 bytes.

Is there any way to prevent the bytes from getting appended to the output
file and rather overwrite the file everytime curl_easy_setopt is called ?

Following is the code sample:

for (i=0; i<4; i++) {
        res = curl_easy_perform(curl_desc);
        if (res != CURLE_OK ) {
        else {

Thanks for your help.
Received on 2008-06-05

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET