1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_SIZE_DOWNLOAD
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_SIZE_DOWNLOAD_T (3)
9  - CURLINFO_SIZE_UPLOAD_T (3)
10  - CURLOPT_MAXFILESIZE (3)
11  - curl_easy_getinfo (3)
12  - curl_easy_setopt (3)
13Protocol:
14  - All
15Added-in: 7.4.1
16---
17
18# NAME
19
20CURLINFO_SIZE_DOWNLOAD - get the number of downloaded bytes
21
22# SYNOPSIS
23
24~~~c
25#include <curl/curl.h>
26
27CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD, double *dlp);
28~~~
29
30# DESCRIPTION
31
32Pass a pointer to a double to receive the total amount of bytes that were
33downloaded. The amount is only for the latest transfer and gets reset again
34for each new transfer. This counts actual payload data, what's also commonly
35called body. All meta and header data is excluded and not included in this
36number.
37
38CURLINFO_SIZE_DOWNLOAD_T(3) is a newer replacement that returns a more
39sensible variable type.
40
41# %PROTOCOLS%
42
43# EXAMPLE
44
45~~~c
46int main(void)
47{
48  CURL *curl = curl_easy_init();
49  if(curl) {
50    CURLcode res;
51    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
52
53    /* Perform the request */
54    res = curl_easy_perform(curl);
55
56    if(!res) {
57      /* check the size */
58      double dl;
59      res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &dl);
60      if(!res) {
61        printf("Downloaded %.0f bytes\n", dl);
62      }
63    }
64  }
65}
66~~~
67
68# DEPRECATED
69
70Deprecated since 7.55.0.
71
72# %AVAILABILITY%
73
74# RETURN VALUE
75
76Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
77