From 7da56ddf5f41f89697855180f506e8c5dd1c5661 Mon Sep 17 00:00:00 2001 From: "Nikita (PodolskyNK)" Date: Mon, 27 May 2024 15:45:36 +0300 Subject: [PATCH] code: 1var solve --- main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index d1f063e..8a1daae 100644 --- a/main.cpp +++ b/main.cpp @@ -43,8 +43,7 @@ write_data(void* items, size_t item_size, size_t item_count, void* ctx) { return data_size; } -Input -download(const string& address) { +Input download(const string& address) { stringstream buffer; CURL *curl = curl_easy_init(); if(curl) { @@ -53,8 +52,13 @@ download(const string& address) { curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); res = curl_easy_perform(curl); - if (res!=CURLE_OK){ - cerr << curl_easy_strerror(res); + if (res != CURLE_OK){ + 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); } curl_easy_cleanup(curl);