1 double zipsize =
0;
2 CURL *handle =
curl_easy_init();
3 curl_easy_setopt(handle, CURLOPT_URL, url);
4 curl_easy_setopt(handle, CURLOPT_HEADER,
1);
//只需要header头
5 curl_easy_setopt(handle, CURLOPT_NOBODY,
1);
//不需要body
6
7 if (curl_easy_perform(handle) ==
CURLE_OK)
8 {
9 curl_easy_getinfo(handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &
zipsize);
10 packageBytesTotal = (
int)((zipsize /
1000) +
0.5);
11 std::cout <<
"当前要加载的包大小为: " << packageBytesTotal <<
"KB" <<
std::endl;
12 }
13 curl_easy_cleanup(handle);
转载于:https://www.cnblogs.com/JD85/p/3914949.html