From f74bc8b658e7f1e655919a3c46425ed66ebbeb46 Mon Sep 17 00:00:00 2001 From: BezhenarAN Date: Sun, 19 May 2024 17:09:29 +0300 Subject: [PATCH] =?UTF-8?q?4.7:=20=D0=B8=D0=BD=D0=B4=D0=B8=D0=B2=D0=B8?= =?UTF-8?q?=D0=B4=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0?= =?UTF-8?q?=D1=80=D0=B8=D0=B0=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.cpp b/main.cpp index e564a47..8abd18f 100644 --- a/main.cpp +++ b/main.cpp @@ -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);