CURLINFO_SIZE_DELIVERED(3)
π 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:
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)CURLINFO_SIZE_DOWNLOAD_T(3)CURLOPT_MAXFILESIZE(3)curl_easy_getinfo(3)curl_easy_setopt(3)
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
- alpine 3.23: curl-doc 8.23.0-r0 Β· curl
- alpine 3.24: curl-doc 8.23.0-r0 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms