|
|
|
@ -72,19 +72,26 @@ Input download(const string &address)
|
|
|
|
|
if (curl)
|
|
|
|
|
{
|
|
|
|
|
CURLcode res;
|
|
|
|
|
double total;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// res = curl_easy_perform(curl);
|
|
|
|
|
|
|
|
|
|
if (res != CURLE_OK)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
|
|
|
|
curl_easy_strerror(res));
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CURLE_OK == res)
|
|
|
|
|
{
|
|
|
|
|
res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total);
|
|
|
|
|
cerr << "Time spending for downloading file: " << total << endl;
|
|
|
|
|
}
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -92,7 +99,6 @@ Input download(const string &address)
|
|
|
|
|
return input_data(buffer, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
Input input;
|
|
|
|
|