CURLINFO_SPEED_DOWNLOAD_T(3)

πŸ’… CURLINFO_SPEED_DOWNLOAD_T πŸ’…

okay bestie, so this one is a page from the Library Functions Manual β€” the curl gang's own little corner of the man pages β€” and it's genuinely so useful, i promise. it's all about finding out how fast your download was going. let's get into it πŸŽ€


✨ NAME ✨

CURLINFO_SPEED_DOWNLOAD_T β€” download speed, aka the vibe check on how quick your bytes arrived πŸ¦‹


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_DOWNLOAD_T,
                           curl_off_t *speed);

✨ DESCRIPTION ✨

so the way this works is iconic: you hand over a pointer to a curl_off_t, and curl fills it in with the average download speed it measured for the complete download. that's the whole entire download, not some sample of it, okay?

and the unit? bytes/second. simple. slay. no conversion needed, no weird multiplier, it's giving straightforward πŸ’…

ngl this is the "how did we do overall" number β€” average across the whole download, so don't come for it if it doesn't match the speed you saw at any one specific moment πŸ™ˆ

✨ PROTOCOLS ✨

this functionality affects all supported protocols ⭐ like, every single one. no exclusions, no "well exceptβ€”". all of them. periodt πŸ‘‘


✨ EXAMPLE ✨

here's the little main character moment in full, exactly as written ✨

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) {
      curl_off_t speed;
      result = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &speed);
      if(!result) {
        printf("Download speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\n",
               speed);
      }
    }
  }
}

see how it sets the URL, performs the request, then asks for the speed? that's the order, bestie β€” the info call comes after the perform. don't skip steps 🫢

also lowkey obsessed with that CURL_FORMAT_CURL_OFF_T macro in the printf β€” it's there so the format string is correct for curl_off_t on whatever platform you're on. use it. always. it's not optional in spirit πŸ’–


✨ AVAILABILITY ✨

Added in curl 7.55.0 β€” so if your curl is older than that, this call simply isn't gonna happen for you, sorry bestie 😭


✨ RETURN VALUE ✨

so curl_easy_getinfo(3) returns a CURLcode that tells you success or error. that's it, that's the return.

  • CURLE_OK (which is 0) β€” everything was OK, you're so back πŸ’–
  • non-zero β€” an error occurred πŸ’€ go check libcurl-errors(3) to see which one it was

no cap, always check it. every single time. it's giving basic hygiene ✨


✨ SEE ALSO ✨

go be nosy, bestie β€” these are all connected πŸ‘€


okay that's the whole page, you ate that πŸ“ and for the record this lil beauty is brought to you by libcurl, dated 2026-10-12 β€” go forth and measure your speeds, icon πŸ’œπŸ§š

πŸ“¦ where this page comes from