1CURLINFO_CONTENT_LENGTH_DOWNcLuOrAlD_(e3a)sy_getinfoCUoRpLtIiNoFnOs_CONTENT_LENGTH_DOWNLOAD(3)
2
3
4

NAME

6       CURLINFO_CONTENT_LENGTH_DOWNLOAD - get content-length of download
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
12                                  double *content_length);
13

DESCRIPTION

15       Pass  a  pointer to a double to receive the content-length of the down‐
16       load. This is the value read  from  the  Content-Length:  field.  Since
17       7.19.4, this returns -1 if the size is not known.
18
19       CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)  is  a newer replacement that re‐
20       turns a more sensible variable type.
21

PROTOCOLS

23       HTTP(S)
24

EXAMPLE

26       CURL *curl = curl_easy_init();
27       if(curl) {
28         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
29
30         /* Perform the request */
31         res = curl_easy_perform(curl);
32
33         if(!res) {
34           /* check the size */
35           double cl;
36           res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
37           if(!res) {
38             printf("Size: %.0f\n", cl);
39           }
40         }
41       }
42

AVAILABILITY

44       Added in 7.6.1
45

RETURN VALUE

47       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
48       if not.
49

SEE ALSO

51       curl_easy_getinfo(3),  curl_easy_setopt(3), CURLINFO_CONTENT_LENGTH_UP‐
52       LOAD(3),
53
54
55
56libcurl 7.85.0                   May 17, 202C2URLINFO_CONTENT_LENGTH_DOWNLOAD(3)
Impressum