CURLINFO_C...H_DOWNLOAD(3)

πŸ’… CURLINFO_CONTENT_LENGTH_DOWNLOAD(3) πŸ’…

🌸 NAME 🌸

okay so this page lives in the Library Functions Manual, bestie, and it is all about CURLINFO_CONTENT_LENGTH_DOWNLOAD β€” content-length of download. no cap πŸ’–


✨ SYNOPSIS ✨

first things first, here is the include and the function signature, exactly as they come:

#include <curl/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. This is the value read from the Content-Length: field. This returns -1 if the size is not known. periodt πŸ’…

CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3) is a newer replacement that returns a more sensible variable type. iykyk ✨


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols. literally all of them, bestie πŸ¦‹


πŸŽ€ EXAMPLE πŸŽ€

here is the whole example, copied with love and zero edits:

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) {
      /* check the size */
      double cl;
      result = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
      if(!result) {
        printf("Size: %.0f\n", cl);
      }
    }
  }
}

πŸ’€ DEPRECATED πŸ’€

Deprecated since 7.55.0. sad but true, bestie 😭


⭐ AVAILABILITY ⭐

Added in curl 7.6.1. iconic vintage behavior πŸ‘‘


🫢 RETURN VALUE 🫢

curl_easy_getinfo(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). that is the whole vibe check βœ…


πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’– this little page comes from libcurl, dated 2026-10-12, and now you know your content-length download tea, bestie. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from