GNURLINFO_...FER_TIME_T(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLINFO_...FER_TIME_T πŸ’…

ok so this is one of the pages from the curl_easy_getinfo options section β€” the manual family is literally called GNURLINFO_...FER_TIME_T(3), which is a mouthful, but you're gonna be fine bestie 🫢


✨ NAME ✨

CURLINFO_PRETRANSFER_TIME_T β€” get the time until the file transfer start πŸ‘‘


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

✨ DESCRIPTION ✨

sooo you pass in a pointer to a curl_off_t and it gets filled with the time β€” in microseconds β€” that it took from the very start until the file transfer is just about to begin. literally the "omg we're almost there" moment ⭐

this number includes all the pre-transfer commands and negotiations that are specific to the particular protocol(s) involved. like all the little handshake-y stuff that's specific to whatever protocol you're on πŸ’…

it does not involve the sending of the protocol-specific request that triggers a transfer. nope, that's not in here, that's a whole different vibe πŸ™ˆ

when a redirect is followed, the time from each request is added together. so redirects stack up, fr fr 🧚

also go peek at the TIMES overview in the curl_easy_getinfo(3) man page, it's giving helpful ✨


✨ PROTOCOLS ✨

All πŸ’€ (every single one, no cap)


✨ EXAMPLE ✨

curl = curl_easy_init();
if(curl) {
  curl_off_t pretransfer;
  curl_easy_setopt(curl, CURLOPT_URL, url);
  res = curl_easy_perform(curl);
  if(CURLE_OK == res) {
    res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T, &pretransfer);
    if(CURLE_OK == res) {
      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", pretransfer / 1000000,
             (long)(pretransfer % 1000000));
    }
  }
  /* always cleanup */
  curl_easy_cleanup(curl);
}

✨ AVAILABILITY ✨

added in 7.61.0 🌈 if you're on anything older, she's not there bestie, sorry 😭


✨ RETURN VALUE ✨

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not πŸŽ€

like, if you get CURLE_UNKNOWN_OPTION it's not you, it's the version πŸ’€

✨ SEE ALSO ✨


🌸 ok that's the whole page, mwah 🫢 this was libcurl 7.61.0, dated 28 Apr 2018 β€” and the manual it lives in is the GNURLINFO_...FER_TIME_T(3) one. go measure your microseconds, main character πŸ’–πŸ¦‹

πŸ“¦ where this page comes from