CURLINFO_PRETRANSFER_TIME_T(3)
π CURLINFO_PRETRANSFER_TIME_T(3) π
okay so bestie, welcome to the Library Functions Manual β yes that's the manual name, and yes we're gonna get into it. This one's all about CURLINFO_PRETRANSFER_TIME_T, and the header up top says it plain: time to transfer start. Periodt. π
β¨ NAME β¨
CURLINFO_PRETRANSFER_TIME_T β literally the time it takes to get to transfer start, no cap.
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_TIME_T,
curl_off_t *timep);
π¦ DESCRIPTION π¦
okay so here's the vibe: you pass in a pointer to a curl_off_t, and it gets filled with the time β in microseconds β that it took from the start until the file transfer is just about to begin. Like, the moment right before things actually pop off. π₯
This timestamp is a whole package deal, iykyk. It includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved. It also includes the sending of the protocol-specific instructions that trigger a transfer. Basically all the behind-the-scenes main character prep work. π
And when a redirect is followed? The time from each request is added together. Every single hop, all summed up. Not me keeping receipts on every redirect π
Also, definitely go peek at the TIMES overview in the curl_easy_getinfo(3) man page β it's giving essential reading. π
π PROTOCOLS π
This functionality affects all supported protocols. Every single one. No gatekeeping. π«Ά
β EXAMPLE β
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_off_t 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_T,
&pretransfer);
if(CURLE_OK == result) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
pretransfer / 1000000,
(long)(pretransfer % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
look at that math splitting out the seconds and microseconds β she ate that ngl π
π§ AVAILABILITY π§
Added in curl 7.61.0. So if you're on something older, that's a no from her, sorry bestie π
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK π β non-zero means an error occurred, so go check libcurl-errors(3) to find out what went down. π
π SEE ALSO π
(yes, this page links to itself, and honestly? iconic. self-referential queen. β)
and that's the whole thing, bestie! π this little beauty comes to you from libcurl, dated 2026-10-12 β go forth and time your pretransfers, mwah ππ¦
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms