4.7: индивидуальный вариант
Этот коммит содержится в:
12
main.cpp
12
main.cpp
@@ -64,15 +64,27 @@ Input download(const string& address) {
|
|||||||
if(curl) {
|
if(curl) {
|
||||||
|
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
|
curl_off_t avspeed;
|
||||||
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);
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
if (res != CURLE_OK) {
|
if (res != CURLE_OK) {
|
||||||
|
|
||||||
curl_easy_strerror(res);
|
curl_easy_strerror(res);
|
||||||
exit(1);
|
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);
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
return input_data(buffer, false);
|
return input_data(buffer, false);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user