1CURLINFO_CONTENT_LENGTH_DOWNcLuOrAlD_(e3a)sy_getinfoCUoRpLtIiNoFnOs_CONTENT_LENGTH_DOWNLOAD(3)
2
3
4
6 CURLINFO_CONTENT_LENGTH_DOWNLOAD - get content-length of download
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWN‐
12 LOAD,
13 double *content_length);
14
16 Pass a pointer to a double to receive the content-length of the down‐
17 load. This is the value read from the Content-Length: field. Since
18 7.19.4, this returns -1 if the size isn't known.
19
20 CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3) is a newer replacement that
21 returns a more sensible variable type.
22
24 HTTP(S)
25
27 CURL *curl = curl_easy_init();
28 if(curl) {
29 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
30
31 /* Perform the request */
32 res = curl_easy_perform(curl);
33
34 if(!res) {
35 /* check the size */
36 double cl;
37 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
38 if(!res) {
39 printf("Size: %.0f\n", cl);
40 }
41 }
42 }
43
45 Added in 7.6.1
46
48 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
49 if not.
50
52 curl_easy_getinfo(3), curl_easy_setopt(3), CURLINFO_CON‐
53 TENT_LENGTH_UPLOAD(3),
54
55
56
57libcurl 7.69.1 June 15, 20C1U7RLINFO_CONTENT_LENGTH_DOWNLOAD(3)