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