code: for my var
Этот коммит содержится в:
12
l03.cpp
12
l03.cpp
@@ -72,19 +72,26 @@ Input download(const string &address)
|
|||||||
if (curl)
|
if (curl)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
|
double total;
|
||||||
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);
|
||||||
|
|
||||||
// res = curl_easy_perform(curl);
|
|
||||||
|
|
||||||
if (res != CURLE_OK)
|
if (res != CURLE_OK)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||||
curl_easy_strerror(res));
|
curl_easy_strerror(res));
|
||||||
exit(1);
|
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);
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +99,6 @@ Input download(const string &address)
|
|||||||
return input_data(buffer, false);
|
return input_data(buffer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Input input;
|
Input input;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user