cURL / Mailing Lists / curl-library / Single Mail

curl-library

ask the reason of curl return "Transferred a partial file"

From: shili <belle.shi_at_yy-inc.com>
Date: Mon, 18 Jul 2011 14:54:19 +0800

hi all:
   recently i used the curl to download the audio file on our server,and
sometimes the curl quit by the reason of "Transferred a partial file",
but when i used the command to download the file, i could download all
of the file, i want to know the reason,what makes the curl return the
error "Transferred a partial file"?and is there any different between
the curl command and the library?

my program code is :
static int player_request_url(char *url,int num,char **heads)
{
    int i=0;
    int res = 0;
    CURL *curl;
    struct curl_slist *chunk = NULL;
    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    if(!curl)
    {
        printf("plugin_request_url_with_head heads num error curl\n");
        return -1;
    }
    curl_get_data=0;
    if(num!=0)
    {
        for(i=0;i<num;i++)
        {
            chunk = curl_slist_append( chunk,heads[i]);
        }
        curl_easy_setopt( curl, CURLOPT_HTTPHEADER, chunk );
    }
    curl_easy_setopt( curl, CURLOPT_HEADERFUNCTION,header_callback);
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_fwrite);
    curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress);
    curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3);
    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
    res = curl_easy_perform(curl);
    double length=0;
    if(res==0)
    {
     curl_easy_getinfo(curl,CURLINFO_CONTENT_LENGTH_DOWNLOAD,&length);
      printf("the length is %d\n",length);
    }
    else
    {
        printf("the network wrong reason %s res %d\n",
curl_easy_strerror(res),res);
    }
    if(chunk!=NULL)
        curl_slist_free_all( chunk );
    curl_easy_cleanup(curl);
    curl_global_cleanup();
    chunk = NULL;
    return res;
}
      

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