CURLINFO_PRETRANSFER_TIME(3)

πŸ’… CURLINFO_PRETRANSFER_TIME πŸ’…

ok so this is a page from the Library Functions Manual, bestie β€” CURLINFO_PRETRANSFER_TIME(3), to be exact. let's get into it ✨


🌸 NAME 🌸

CURLINFO_PRETRANSFER_TIME β€” literally the time it takes to get to the start of the transfer 🫢


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_TIME,
                           double *timep);

πŸŽ€ DESCRIPTION πŸŽ€

okay so picture this: you pass in a pointer to a double, and it gets filled with the time β€” in seconds β€” from the very start all the way up until the file transfer is just about to begin. like, the calm before the slay πŸ’…

this time-stamp includes all the pre-transfer commands and negotiations that are specific to whatever protocol(s) you're dealing with. it includes sending the protocol-specific instructions that trigger a transfer. no cap, all of that is in there πŸ”₯

and when a redirect is followed? the time from each request gets added together. every single one. periodt πŸ’€

also go check out the TIMES overview in the curl_easy_getinfo(3) man page β€” it's giving essential reading 🌈


πŸ¦‹ PROTOCOLS πŸ¦‹

this functionality affects all supported protocols. all of them. every last one πŸ‘‘


πŸ“ EXAMPLE πŸ“

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    double pretransfer;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    result = curl_easy_perform(curl);
    if(CURLE_OK == result) {
      result = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME,
                                 &pretransfer);
      if(CURLE_OK == result) {
        printf("Time: %.1f", pretransfer);
      }
    }
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

⭐ AVAILABILITY ⭐

added in curl 7.4.1 β€” vintage icon behavior, honestly πŸ‘‘


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_getinfo(3) returns a CURLcode indicating success or error. that's it, that's the vibe check ✨

CURLE_OK (0) means everything was OK β€” slay πŸŽ‰ β€” and a non-zero value means an error occurred, so go peek at libcurl-errors(3) 😭


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie 🧚 this one came from libcurl dated 2026-10-12 β€” go forth and time your pretransfers πŸ’–πŸŽ€

πŸ“¦ where this page comes from