GNURLINFO_SIZE_DOWNLOAD(3)
π 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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms