GNURLINFO...H_DOWNLOAD(3)
β¨ NAME β¨
okay so we're on the GNURLINFO...H_DOWNLOAD(3) page from the curl_easy_getinfo options manual, and the main character is CURLINFO_CONTENT_LENGTH_DOWNLOAD β literally get content-length of download, bestie. no cap. π
π SYNOPSIS π
#include <gnurl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle,
CURLINFO_CONTENT_LENGTH_DOWNLOAD,
double *content_length);
π DESCRIPTION π
Pass a pointer to a double to receive the content-length of the download. That's the value read from the Content-Length: field, fr fr. Since 7.19.4, this returns -1 if the size isn't known. π
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3) is the newer replacement, and it returns a more sensible variable type. iconic behavior, but this one is still here doing its thing. β¨
π PROTOCOLS π
HTTP(S) β that's the vibe. π¦
π EXAMPLE π
Here's the example, untouched and slaying:
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 cl;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
if(!res) {
printf("Size: %.0f\n", cl);
}
}
}
β AVAILABILITY β
Added in 7.6.1 β vintage but still cute. π
π RETURN VALUE π
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's the whole mood. π
π¦ SEE ALSO π¦
go read those too, iykyk. π«Ά
xoxo, your Unix bestie π β this page is from libcurl 7.44.0, dated 1 Sep 2015, and yes the manual-page header energy is GNURLINFO...H_DOWNLOAD(3) all day. periodt. πΈ
π¦ 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