Nikita (PodolskyNK) 11 месяцев назад
Родитель fcd8a546ad
Сommit 7da56ddf5f

@ -43,8 +43,7 @@ write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
return data_size; return data_size;
} }
Input Input download(const string& address) {
download(const string& address) {
stringstream buffer; stringstream buffer;
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
if(curl) { if(curl) {
@ -53,8 +52,13 @@ download(const string& address) {
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);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res!=CURLE_OK){ if (res != CURLE_OK){
cerr << curl_easy_strerror(res); double total_time;
if (!curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time)){;
cerr << "Total time for download: " << total_time << " seconds." << "CURL error: " << curl_easy_strerror(res) << endl;
} else {
cerr << "CURL error: " << curl_easy_strerror(res) << endl;
}
exit(1); exit(1);
} }
curl_easy_cleanup(curl); curl_easy_cleanup(curl);

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