CURLINFO_SIZE_DOWNLOAD_T(3)

✨ CURLINFO_SIZE_DOWNLOAD_T(3) ✨

okay bestie, welcome to the Library Functions Manual πŸ’– this one's a lil curl page about counting your bytes, and honestly? it's giving "small but mighty." πŸ¦‹


🌸 NAME 🌸

CURLINFO_SIZE_DOWNLOAD_T β€” number of downloaded bytes πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD_T,
                           curl_off_t *dlp);

✨ DESCRIPTION ✨

so basically, you pass a pointer to a curl_off_t β€” that's where the answer lands 🫢 β€” and it receives the total amount of bytes that were downloaded.

couple things to know, no cap:

  • the amount is only for the latest transfer, and it gets reset again for each new transfer πŸ”
  • this counts actual payload data, what's also commonly called body πŸ’–
  • all meta and header data is excluded from this amount πŸ™ˆ

like, it's the meat of the download, not the packaging. periodt. πŸ‘‘


🌈 PROTOCOLS 🌈

this functionality affects all supported protocols β€” every single one, bestie, no favorites πŸ’€βœ¨


🧚 EXAMPLE 🧚

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

    /* Perform the request */
    result = curl_easy_perform(curl);

    if(!result) {
      /* check the size */
      curl_off_t dl;
      result = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &dl);
      if(!result) {
        printf("Downloaded %" CURL_FORMAT_CURL_OFF_T " bytes\n", dl);
      }
    }
  }
}

look at that little printf go πŸ˜­πŸ’– iconic behavior, honestly.


⭐ AVAILABILITY ⭐

added in curl 7.55.0 β€” a classic, we stan a veteran πŸŽ€


πŸ‘‘ RETURN VALUE πŸ‘‘

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK βœ… β€” non-zero means an error occurred 😭, see libcurl-errors(3) for the whole vibe check.


πŸ¦‹ SEE ALSO πŸ¦‹


ngl, go read those too. iykyk πŸ’…

mwah πŸ’‹ bye bestie, go count those bytes β€” this page is from libcurl, dated 2026-10-12, and it's the CURLINFO_SIZE_DOWNLOAD_T(3) entry, slay πŸ’–βœ¨

πŸ“¦ where this page comes from