diff --git a/main.cpp b/main.cpp index 95fa242..1ad4ce6 100644 --- a/main.cpp +++ b/main.cpp @@ -60,21 +60,26 @@ Input download(const string& address) if(curl) { CURLcode res; + double start; + 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); curl_easy_cleanup(curl); - if (res != 0) + if (res == CURLE_OK) { - cerr << curl_easy_strerror(res) << endl; - exit(1); + res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &start); + if (CURLE_OK == res) + { + cerr<<"Time: " << start; + } } - } - curl_easy_cleanup(curl); + curl_easy_cleanup(curl); - return input_data(buffer, false); + return input_data(buffer, false); + } } @@ -111,11 +116,15 @@ Input download(const string& address) return 0; } */ -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ Input input; - if (argc > 1) { + if (argc > 1) + { input = download(argv[1]); - } else { + } + else + { input = input_data(cin, true); }