diff --git a/main.cpp b/main.cpp index e1bfe89..b1636b0 100644 --- a/main.cpp +++ b/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);