PARZIVAL (BreganIM) 4 недель назад
Родитель e32d622ada
Сommit ef0fcfca11

@ -39,7 +39,7 @@ static size_t write_data(void* items, size_t item_size, size_t item_count, void*
Input download(const string& address) { Input download(const string& address) {
stringstream buffer; stringstream buffer;
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
@ -49,6 +49,11 @@ Input download(const string& address) {
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
exit(1); exit(1);
} }
double download_speed = 0.0;
curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &download_speed);
cerr << "Download speed: " << download_speed << " bytes/sec\n";
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
return input_data(buffer, false); return input_data(buffer, false);
} }

Загрузка…
Отмена
Сохранить