|
|
|
@ -64,15 +64,27 @@ Input download(const string& address) {
|
|
|
|
|
if(curl) {
|
|
|
|
|
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_off_t avspeed;
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &avspeed);
|
|
|
|
|
if (res != 0) {
|
|
|
|
|
curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cerr << "Average speed: " << avspeed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
}
|
|
|
|
|
return input_data(buffer, false);
|
|
|
|
|