CURLINFO_P...FER_TIME_T(3)

πŸ’… CURLINFO_POSTTRANSFER_TIME_T β€” bestie's guide to timing

okay so this one is from the Library Functions Manual (libcurl girlies rise up ✨) and it's all about how long it took to get that last byte out the door. Let's go πŸŽ€


✨ NAME ✨

CURLINFO_POSTTRANSFER_TIME_T β€” the time it took to send the last byte, periodt πŸ’Œ

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_POSTTRANSFER_TIME_T,
                           curl_off_t *timep);

✨ DESCRIPTION ✨

So here's the vibe πŸ¦‹ β€” you pass a pointer to a curl_off_t, and it receives the time, in microseconds, that it took from the start until the last byte is sent by libcurl. Literally the moment the very last byte leaves the building πŸ‘‘.

And when a redirect is followed? Not me forgetting β€” the time from each request is added together, fr fr. Every hop counts 🫢.

Also lowkey go look at the TIMES overview in the curl_easy_getinfo(3) man page, iykyk.

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols β€” she's versatile, she contains multitudes ✨

🌸 EXAMPLE 🌸

like, here's how you'd actually use her:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    result = curl_easy_perform(curl);
    if(CURLE_OK == result) {
      curl_off_t posttransfer;
      result = curl_easy_getinfo(curl, CURLINFO_POSTTRANSFER_TIME_T,
                              &posttransfer);
      if(CURLE_OK == result) {
        printf("Request sent after: %" CURL_FORMAT_CURL_OFF_T ".%06ld s",
               posttransfer / 1000000, (long)(posttransfer % 1000000));
      }
    }
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

(and yes bestie, /* always cleanup */ is non-negotiable β€” curl_easy_cleanup(curl) always πŸ’…)

⭐ AVAILABILITY ⭐

Added in curl 8.10.0 β€” she's a newer icon, born in 8.10.0, respect her πŸŽ€

πŸ’– RETURN VALUE πŸ’–

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

CURLE_OK (0) means everything was OK β€” slay πŸ’…. Anything non-zero means an error occurred, so go see libcurl-errors(3) and figure out what went wrong 😭.

πŸ¦‹ SEE ALSO πŸ¦‹


ngl, microseconds are tiny but this info is main character energy β€” measure your sends, know your timing πŸ”₯

later besties πŸ’œ this page was brought to you by libcurl, dated 2026-10-12, straight out of the Library Functions Manual β€” mwah 🫢✨

πŸ“¦ where this page comes from