cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl win32 package - image download corrupted

From: Opel Fahrer <opelfahrer79_at_yahoo.de>
Date: Thu, 29 Sep 2011 17:49:59 +0100 (BST)

Hi,

I used this package to build a script for Win32, which should fetch an image from a server:

http://curl.haxx.se/download/libcurl-7.19.3-win32-ssl-msvc.zip

Unfortunately the images downloaded are all corrupted.

Here's the code for grabbing the image:

{{{
    CURL *curl_handle;
   
    // get argument
    char * query[] = "http://blog.evermeet.cx/uploads/camaro.jpg";   
    char * separator = strrchr(query,'/');
    char * filename = separator+1;
   
    curl_global_init(CURL_GLOBAL_ALL);
     
    // init the curl session
    curl_handle = curl_easy_init();
   
    // set URL to get
    curl_easy_setopt(curl_handle, CURLOPT_URL, query);
   
    // no progress meter please
    curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
   
    // send all data to this function
    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);

    FILE* outputfile = fopen(filename,"w");   
    if (outputfile == NULL) {
        curl_easy_cleanup(curl_handle);
        printf("Error opening file.");;
    }
    // write to a file
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, outputfile);
   
    // get it!
    curl_easy_perform(curl_handle);
     
    fclose(outputfile);
        
    // cleanup curl stuff */
    curl_easy_cleanup(curl_handle);
      
    // we're done with libcurl, so clean it up 
    curl_global_cleanup();
}}}

I tested it with various examples, eg. 'http://blog.evermeet.cx/uploads/camaro.jpg', and the image is corrupted (can be displayed, but has a lot of errors). Other images download but the image can't be opened due to "bogus huffman table" errors (according to Irfanview). I compared an image with its corrupted version and it seems that there are single bytes missing in between, or are flipped - I can't make sense out of it, but for an aproximately 80kB image, I had 6 bytes missing in the entire bytestream and that caused the mess.

Can somebody check this? I suspect that it is a bug somewhere in the libcurl code, since the same stuff works great on OSX.

Cheers,
OP

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-29