|
|
|
@ -49,15 +49,23 @@ download(const string& address)
|
|
|
|
|
if(curl)
|
|
|
|
|
{
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_off_t speed;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
|
|
|
|
|
if (res != CURLE_OK)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &speed);
|
|
|
|
|
if(!res)
|
|
|
|
|
{
|
|
|
|
|
cerr<<"Download speed bytes/sec: " <<speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|