GNURLINFO...DOWNLOAD_T(3)
π CURLINFO_CONTENT_LENGTH_DOWNLOAD_T β get content-length of download
okay bestie, so this page lives in the curl_easy_getinfo options family β the manual name is literally GNURLINFO...DOWNLOAD_T(3), iconic little corner of the gnurl world. let's get into it π
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle,
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
curl_off_t *content_length);
πΈ DESCRIPTION πΈ
so you pass a pointer to a curl_off_t, right? and it gets filled with the content-length of the download. that's the value read straight from the Content-Length: field. and if the size isn't known? it just stores -1. no cap, that's it. π
π¦ PROTOCOLS π¦
HTTP(S) β that's the vibe check, only these two π
β 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 */
curl_off_t cl;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl);
if(!res) {
printf("Download size: %" CURL_FORMAT_CURL_OFF_T "\n", cl);
}
}
}
literally the whole glow-up in one snippet π«Ά
π AVAILABILITY π
Added in 7.55.0 β she's been here a minute, lowkey a legend β¨
π RETURN VALUE π
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's the whole tea β
π SEE ALSO π
ngl, this one's a short read but it ate. go check your download sizes, bestie π
sign-off szn: this page ships with libcurl 7.55.0, dated 25 May 2017 β and the manual slot it lives in is GNURLINFO...DOWNLOAD_T(3) π§π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, 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