1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_PRETRANSFER_TIME_T
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_CONNECT_TIME (3)
9  - CURLINFO_PRETRANSFER_TIME_T (3)
10  - curl_easy_getinfo (3)
11  - curl_easy_setopt (3)
12---
13
14# NAME
15
16CURLINFO_PRETRANSFER_TIME_T - get the time until the file transfer start
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_TIME_T,
24                           curl_off_t *timep);
25~~~
26
27# DESCRIPTION
28
29Pass a pointer to a curl_off_t to receive the time, in microseconds, it took
30from the start until the file transfer is just about to begin.
31
32This time-stamp includes all pre-transfer commands and negotiations that are
33specific to the particular protocol(s) involved. It includes the sending of
34the protocol-specific instructions that trigger a transfer.
35
36When a redirect is followed, the time from each request is added together.
37
38See also the TIMES overview in the curl_easy_getinfo(3) man page.
39
40# PROTOCOLS
41
42All
43
44# EXAMPLE
45
46~~~c
47int main(void)
48{
49  CURL *curl = curl_easy_init();
50  if(curl) {
51    CURLcode res;
52    curl_off_t pretransfer;
53    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
54    res = curl_easy_perform(curl);
55    if(CURLE_OK == res) {
56      res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T, &pretransfer);
57      if(CURLE_OK == res) {
58        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
59               pretransfer / 1000000,
60               (long)(pretransfer % 1000000));
61      }
62    }
63    /* always cleanup */
64    curl_easy_cleanup(curl);
65  }
66}
67~~~
68
69# AVAILABILITY
70
71Added in 7.61.0
72
73# RETURN VALUE
74
75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
76