GNURLINFO_...FER_TIME_T(3)

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

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

okay so listen bestie, this is a page from the curl_easy_getinfo options manual, and it's genuinely one of the cutest little stats you can pull out of libcurl. it's giving stopwatch energy, fr fr. let's get into it πŸŽ€


✨ NAME ✨

CURLINFO_STARTTRANSFER_TIME_T β€” get the time until the first byte is received πŸ•βœ¨


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

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

πŸ’– DESCRIPTION πŸ’–

so you pass a pointer to a curl_off_t, right? and it receives the time, in microseconds, that it took from the start until the first byte is received by libcurl. that's the whole vibe. ⏱️

and bestie, it's not just the transfer β€” this number includes CURLINFO_PRETRANSFER_TIME_T(3) and also the time the server needs to calculate the result. so it's the full "waiting for the server to get its life together" moment 🫢

heads up: when a redirect is followed, the time from each request is added together. no cap, it just stacks. πŸ”

also see the TIMES overview in the curl_easy_getinfo(3) man page if you wanna go deeper, iykyk πŸ‘‘


πŸ¦‹ PROTOCOLS πŸ¦‹

All β€” literally all of them, slay πŸ’…


πŸ“ EXAMPLE πŸ“

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

look at her go 🧚 dividing by 1000000 to get seconds, modding by 1000000 for the microsecond bits β€” iconic math, no notes πŸ’œ


⭐ AVAILABILITY ⭐

Added in 7.61.0 🌈


πŸ”₯ RETURN VALUE πŸ”₯

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's it, that's the check πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie!! this one's from libcurl 7.61.0, dated 28 Apr 2018, and it lives in the GNURLINFO_...FER_TIME_T(3) section of the manual πŸŽ€βœ¨ mwah, go time some transfers πŸ’–

πŸ“¦ where this page comes from