code: added connection timer
Этот коммит содержится в:
7
main.cpp
7
main.cpp
@@ -67,6 +67,7 @@ download(const string& address) {
|
||||
CURL* curl = curl_easy_init();
|
||||
if (curl) {
|
||||
CURLcode res;
|
||||
curl_off_t connect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||
@@ -75,6 +76,12 @@ download(const string& address) {
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||
exit(1);
|
||||
}
|
||||
if (CURLE_OK == res) {
|
||||
res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &connect);
|
||||
if (CURLE_OK == res) {
|
||||
fprintf(stderr, "connection time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000, (long)(connect % 1000000));
|
||||
}
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return input_data(buffer, false);
|
||||
|
||||
Ссылка в новой задаче
Block a user