GNURLINFO_SIZE_DOWNLOAD(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLINFO_SIZE_DOWNLOAD β€” bestie's guide to the curl_easy_getinfo options page πŸ’…

ok so, this is from the curl_easy_getinfo options manual section, and the star of the show today is CURLINFO_SIZE_DOWNLOAD, which literally just tells you how many bytes you downloaded. No cap. Let's get into it 🫢


✨ NAME ✨

CURLINFO_SIZE_DOWNLOAD β€” get the number of downloaded bytes πŸ“


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD, double *dlp);

πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the vibe: you pass in a pointer to a double, and it gets filled with the total amount of bytes that were downloaded. that's it, that's the whole thing πŸ’–

couple things to know though, bestie, and these matter:

  • the amount is only for the latest transfer β€” it gets reset again for each new transfer, so don't be out here thinking it's a lifetime total 😭
  • it counts actual payload data, like what everyone commonly calls the body
  • all meta and header data are excluded and will not be counted in this number πŸ™ˆ

also, heads up: CURLINFO_SIZE_DOWNLOAD_T(3) is a newer replacement that returns a more sensible variable type. so like, it exists, it's iconic, but this one still works. iykyk πŸ’…


πŸ¦‹ PROTOCOLS πŸ¦‹

All ✨ β€” every single one, no gatekeeping.


πŸ”₯ EXAMPLE πŸ”₯

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

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

  if(!res) {
    /* check the size */
    double dl;
    res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &dl);
    if(!res) {
      printf("Downloaded %.0f bytes\n", cl);
    }
  }
}

look at that. it's giving "i just want to know how big my download was" and honestly? relatable πŸ‘‘


🌈 AVAILABILITY 🌈

Added in 7.4.1 β€” so she's been around a minute, an absolute veteran fr fr ⭐


πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple as that, no drama πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘


k that's the whole page, you ate that, go log some bytes πŸ§šπŸ’–

mwah πŸ’‹ β€” this was pulled from libcurl 7.44.0, dated 28 Aug 2015, and that's the tea πŸŽ€

πŸ“¦ where this page comes from