CURLINFO_SIZE_DELIVERED(3)

πŸ“¦
version 8.23.0 Β· 5 versions
, in alpine 3.23, alpine 3.24

πŸ’– CURLINFO_SIZE_DELIVERED(3) πŸ’–

okay so picture this: you're deep in the libcurl manual, the Library Functions Manual section, and you land on CURLINFO_SIZE_DELIVERED β€” bestie, this one is about the number of delivered bytes. that's literally the whole NAME. slay.


✨ SYNOPSIS ✨

like always, you gotta bring the header in first:

#include <curl/curl.h>

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

that's the whole vibe. one function, three args, no cap. 🫢


🌸 DESCRIPTION 🌸

so here's the tea: you pass a pointer to a curl_off_t (dlp), and it gets filled with the total amount of bytes that were passed on to the write callback during the download. periodt.

a couple things to keep in your notes app though:

  • this amount is only for the latest transfer β€” it gets reset again for each new transfer. so don't be out here thinking it's cumulative, because it is NOT. πŸ’€
  • it counts actual payload data, what everyone also commonly calls the body. iconic.
  • all meta and header data is excluded from this amount β€” unless CURLOPT_HEADER(3) is set. then, well, header bytes are in the mix too, iykyk.

and here's the part that trips people up β€” the delivered size may differ from the size you get with CURLINFO_SIZE_DOWNLOAD_T(3) when CURLOPT_ACCEPT_ENCODING(3) is used for automatic data decompression. why? because this one is then the size of the uncompressed body, while CURLINFO_SIZE_DOWNLOAD_T(3) returns the size of the download. two different numbers, both valid, don't @ me. πŸ¦‹


🌈 PROTOCOLS 🌈

this functionality affects all supported protocols. all of them. every single one. main character energy fr fr πŸ‘‘


πŸŽ€ EXAMPLE πŸŽ€

here's the whole thing, copied exactly because code is sacred:

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 == CURLE_OK) {
      /* check the size */
      curl_off_t dl;
      result = curl_easy_getinfo(curl, CURLINFO_SIZE_DELIVERED, &dl);
      if(result == CURLE_OK) {
        printf("Stored %" CURL_FORMAT_CURL_OFF_T " bytes\n", dl);
      }
    }
  }
}

init the handle, set the URL, perform the request, then grab the size and print it. chef's kiss, ate, no crumbs. πŸ’…


⭐ AVAILABILITY ⭐

Added in curl 8.20.0. so if you're on anything older, sorry bestie, this one's not for you yet 😭


πŸ’œ 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 β€” go check libcurl-errors(3) for what went wrong
ngl, always check that return value. every time. it's giving self-care. 🩷

πŸ¦‹ SEE ALSO πŸ¦‹

the mandatory reading list, a.k.a. the group chat:


and that's the page!! πŸ’– this lil write-up lives in the libcurl manual, dated 2026-10-25, and it's brought to you by the fine folks behind libcurl β€” go drink some water and read the next manpage, mwah πŸ§šβ€β™€οΈπŸŽ€

πŸ“¦ where this page comes from