xref: /curl/docs/libcurl/curl_easy_getinfo.md (revision 3040971d)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_easy_getinfo
5Section: 3
6Source: libcurl
7See-also:
8  - curl_easy_setopt (3)
9Protocol:
10  - All
11Added-in: 7.4.1
12---
13
14# NAME
15
16curl_easy_getinfo - extract information from a curl handle
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
24~~~
25
26# DESCRIPTION
27
28Get the *info* kept in the *curl* handle. The third argument **MUST** be
29pointing to the specific type of the used option which is documented in each
30man page of the *info* option. The data is stored accordingly and can be
31relied upon only if this function returns CURLE_OK. Use this function after a
32performed transfer if you want to get transfer related data.
33
34You should not free the memory returned by this function unless it is
35explicitly mentioned below.
36
37# OPTIONS
38
39The following information can be extracted:
40
41## CURLINFO_ACTIVESOCKET
42
43The session's active socket. See CURLINFO_ACTIVESOCKET(3)
44
45## CURLINFO_APPCONNECT_TIME
46
47The time it took from the start until the SSL connect/handshake with the
48remote host was completed as a double in number of seconds. (Added in 7.19.0)
49
50## CURLINFO_APPCONNECT_TIME_T
51
52The time it took from the start until the SSL connect/handshake with the
53remote host was completed in number of microseconds. (Added in 7.60.0) See
54CURLINFO_APPCONNECT_TIME_T(3)
55
56## CURLINFO_CAINFO
57
58Get the default value for CURLOPT_CAINFO(3). See CURLINFO_CAINFO(3)
59
60## CURLINFO_CAPATH
61
62Get the default value for CURLOPT_CAPATH(3). See CURLINFO_CAPATH(3)
63
64## CURLINFO_CERTINFO
65
66Certificate chain. See CURLINFO_CERTINFO(3)
67
68## CURLINFO_CONDITION_UNMET
69
70Whether or not a time conditional was met or 304 HTTP response.
71See CURLINFO_CONDITION_UNMET(3)
72
73## CURLINFO_CONNECT_TIME
74
75The time it took from the start until the connect to the remote host (or
76proxy) was completed. As a double. See CURLINFO_CONNECT_TIME(3)
77
78## CURLINFO_CONNECT_TIME_T
79
80The time it took from the start until the connect to the remote host (or
81proxy) was completed. In microseconds. See CURLINFO_CONNECT_TIME_T(3).
82
83## CURLINFO_CONN_ID
84
85The ID of the last connection used by the transfer. (Added in 8.2.0)
86See CURLINFO_CONN_ID(3)
87
88## CURLINFO_CONTENT_LENGTH_DOWNLOAD
89
90(**Deprecated**) Content length from the Content-Length header.
91See CURLINFO_CONTENT_LENGTH_DOWNLOAD(3)
92
93## CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
94
95Content length from the Content-Length header.
96See CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)
97
98## CURLINFO_CONTENT_LENGTH_UPLOAD
99
100(**Deprecated**) Upload size. See CURLINFO_CONTENT_LENGTH_UPLOAD(3)
101
102## CURLINFO_CONTENT_LENGTH_UPLOAD_T
103
104Upload size. See CURLINFO_CONTENT_LENGTH_UPLOAD_T(3)
105
106## CURLINFO_CONTENT_TYPE
107
108Content type from the `Content-Type:` header. We recommend using
109curl_easy_header(3) instead. See CURLINFO_CONTENT_TYPE(3)
110
111## CURLINFO_COOKIELIST
112
113List of all known cookies. See CURLINFO_COOKIELIST(3)
114
115## CURLINFO_EARLYDATA_SENT_T
116
117Amount of TLS early data sent (in number of bytes) when
118CURLSSLOPT_EARLYDATA is enabled.
119
120## CURLINFO_EFFECTIVE_METHOD
121
122Last used HTTP method. See CURLINFO_EFFECTIVE_METHOD(3)
123
124## CURLINFO_EFFECTIVE_URL
125
126Last used URL. See CURLINFO_EFFECTIVE_URL(3)
127
128## CURLINFO_FILETIME
129
130Remote time of the retrieved document. See CURLINFO_FILETIME(3)
131
132## CURLINFO_FILETIME_T
133
134Remote time of the retrieved document. See CURLINFO_FILETIME_T(3)
135
136## CURLINFO_FTP_ENTRY_PATH
137
138The entry path after logging in to an FTP server. See
139CURLINFO_FTP_ENTRY_PATH(3)
140
141## CURLINFO_HEADER_SIZE
142
143Number of bytes of all headers received. See CURLINFO_HEADER_SIZE(3)
144
145## CURLINFO_HTTPAUTH_AVAIL
146
147Available HTTP authentication methods. See CURLINFO_HTTPAUTH_AVAIL(3)
148
149## CURLINFO_HTTP_CONNECTCODE
150
151Last proxy CONNECT response code. See CURLINFO_HTTP_CONNECTCODE(3)
152
153## CURLINFO_HTTP_VERSION
154
155The http version used in the connection. See CURLINFO_HTTP_VERSION(3)
156
157## CURLINFO_LASTSOCKET
158
159(**Deprecated**) Last socket used. See CURLINFO_LASTSOCKET(3)
160
161## CURLINFO_LOCAL_IP
162
163Source IP address of the last connection. See CURLINFO_LOCAL_IP(3)
164
165## CURLINFO_LOCAL_PORT
166
167Source port number of the last connection. See CURLINFO_LOCAL_PORT(3)
168
169## CURLINFO_NAMELOOKUP_TIME
170
171Time from start until name resolving completed as a double. See
172CURLINFO_NAMELOOKUP_TIME(3)
173
174## CURLINFO_NAMELOOKUP_TIME_T
175
176Time from start until name resolving completed in number of microseconds. See
177CURLINFO_NAMELOOKUP_TIME_T(3)
178
179## CURLINFO_NUM_CONNECTS
180
181Number of new successful connections used for previous transfer.
182See CURLINFO_NUM_CONNECTS(3)
183
184## CURLINFO_OS_ERRNO
185
186The errno from the last failure to connect. See CURLINFO_OS_ERRNO(3)
187
188## CURLINFO_POSTTRANSFER_TIME_T
189
190The time it took from the start until the last byte is sent by libcurl.
191In microseconds. (Added in 8.10.0) See CURLINFO_POSTTRANSFER_TIME_T(3)
192
193## CURLINFO_PRETRANSFER_TIME
194
195The time it took from the start until the file transfer is just about to
196begin. This includes all pre-transfer commands and negotiations that are
197specific to the particular protocol(s) involved. See
198CURLINFO_PRETRANSFER_TIME(3)
199
200## CURLINFO_PRETRANSFER_TIME_T
201
202The time it took from the start until the file transfer is just about to
203begin. This includes all pre-transfer commands and negotiations that are
204specific to the particular protocol(s) involved. In microseconds. See
205CURLINFO_PRETRANSFER_TIME_T(3)
206
207## CURLINFO_PRIMARY_IP
208
209Destination IP address of the last connection. See CURLINFO_PRIMARY_IP(3)
210
211## CURLINFO_PRIMARY_PORT
212
213Destination port of the last connection. See CURLINFO_PRIMARY_PORT(3)
214
215## CURLINFO_PRIVATE
216
217User's private data pointer. See CURLINFO_PRIVATE(3)
218
219## CURLINFO_PROTOCOL
220
221(**Deprecated**) The protocol used for the connection. (Added in 7.52.0) See
222CURLINFO_PROTOCOL(3)
223
224## CURLINFO_PROXYAUTH_AVAIL
225
226Available HTTP proxy authentication methods. See CURLINFO_PROXYAUTH_AVAIL(3)
227
228## CURLINFO_PROXY_ERROR
229
230Detailed proxy error. See CURLINFO_PROXY_ERROR(3)
231
232## CURLINFO_PROXY_SSL_VERIFYRESULT
233
234Proxy certificate verification result. See CURLINFO_PROXY_SSL_VERIFYRESULT(3)
235
236## CURLINFO_QUEUE_TIME_T
237
238The time during which the transfer was held in a waiting queue before it could
239start for real in number of microseconds. (Added in 8.6.0) See
240CURLINFO_QUEUE_TIME_T(3)
241
242## CURLINFO_REDIRECT_COUNT
243
244Total number of redirects that were followed. See CURLINFO_REDIRECT_COUNT(3)
245
246## CURLINFO_REDIRECT_TIME
247
248The time it took for all redirection steps include name lookup, connect,
249pretransfer and transfer before final transaction was started. So, this is
250zero if no redirection took place. As a double. See CURLINFO_REDIRECT_TIME(3)
251
252## CURLINFO_REDIRECT_TIME_T
253
254The time it took for all redirection steps include name lookup, connect,
255pretransfer and transfer before final transaction was started. So, this is
256zero if no redirection took place. In number of microseconds. See
257CURLINFO_REDIRECT_TIME_T(3)
258
259## CURLINFO_REDIRECT_URL
260
261URL a redirect would take you to, had you enabled redirects. See
262CURLINFO_REDIRECT_URL(3)
263
264## CURLINFO_REFERER
265
266Referrer header. See CURLINFO_REFERER(3)
267
268## CURLINFO_REQUEST_SIZE
269
270Number of bytes sent in the issued HTTP requests. See CURLINFO_REQUEST_SIZE(3)
271
272## CURLINFO_RESPONSE_CODE
273
274Last received response code. See CURLINFO_RESPONSE_CODE(3)
275
276## CURLINFO_RETRY_AFTER
277
278The value from the Retry-After header. See CURLINFO_RETRY_AFTER(3)
279
280## CURLINFO_RTSP_CLIENT_CSEQ
281
282The RTSP client CSeq that is expected next. See CURLINFO_RTSP_CLIENT_CSEQ(3)
283
284## CURLINFO_RTSP_CSEQ_RECV
285
286RTSP CSeq last received. See CURLINFO_RTSP_CSEQ_RECV(3)
287
288## CURLINFO_RTSP_SERVER_CSEQ
289
290The RTSP server CSeq that is expected next. See CURLINFO_RTSP_SERVER_CSEQ(3)
291
292## CURLINFO_RTSP_SESSION_ID
293
294RTSP session ID. See CURLINFO_RTSP_SESSION_ID(3)
295
296## CURLINFO_SCHEME
297
298The scheme used for the connection. (Added in 7.52.0) See CURLINFO_SCHEME(3)
299
300## CURLINFO_SIZE_DOWNLOAD
301
302(**Deprecated**) Number of bytes downloaded. See CURLINFO_SIZE_DOWNLOAD(3)
303
304## CURLINFO_SIZE_DOWNLOAD_T
305
306Number of bytes downloaded. See CURLINFO_SIZE_DOWNLOAD_T(3)
307
308## CURLINFO_SIZE_UPLOAD
309
310(**Deprecated**) Number of bytes uploaded. See CURLINFO_SIZE_UPLOAD(3)
311
312## CURLINFO_SIZE_UPLOAD_T
313
314Number of bytes uploaded. See CURLINFO_SIZE_UPLOAD_T(3)
315
316## CURLINFO_SPEED_DOWNLOAD
317
318(**Deprecated**) Average download speed. See CURLINFO_SPEED_DOWNLOAD(3)
319
320## CURLINFO_SPEED_DOWNLOAD_T
321
322Average download speed. See CURLINFO_SPEED_DOWNLOAD_T(3)
323
324## CURLINFO_SPEED_UPLOAD
325
326(**Deprecated**) Average upload speed. See CURLINFO_SPEED_UPLOAD(3)
327
328## CURLINFO_SPEED_UPLOAD_T
329
330Average upload speed in number of bytes per second. See
331CURLINFO_SPEED_UPLOAD_T(3)
332
333## CURLINFO_SSL_ENGINES
334
335A list of OpenSSL crypto engines. See CURLINFO_SSL_ENGINES(3)
336
337## CURLINFO_SSL_VERIFYRESULT
338
339Certificate verification result. See CURLINFO_SSL_VERIFYRESULT(3)
340
341## CURLINFO_STARTTRANSFER_TIME
342
343The time it took from the start until the first byte is received by libcurl.
344As a double. See CURLINFO_STARTTRANSFER_TIME(3)
345
346## CURLINFO_STARTTRANSFER_TIME_T
347
348The time it took from the start until the first byte is received by libcurl.
349In microseconds. See CURLINFO_STARTTRANSFER_TIME_T(3)
350
351## CURLINFO_TLS_SESSION
352
353(**Deprecated**) TLS session info that can be used for further processing. See
354CURLINFO_TLS_SESSION(3). Use CURLINFO_TLS_SSL_PTR(3) instead.
355
356## CURLINFO_TLS_SSL_PTR
357
358TLS session info that can be used for further processing. See
359CURLINFO_TLS_SSL_PTR(3)
360
361## CURLINFO_TOTAL_TIME
362
363Total time of previous transfer. See CURLINFO_TOTAL_TIME(3)
364
365## CURLINFO_TOTAL_TIME_T
366
367Total time of previous transfer. See CURLINFO_TOTAL_TIME_T(3)
368
369## CURLINFO_USED_PROXY
370
371Whether the proxy was used (Added in 8.7.0). See CURLINFO_USED_PROXY(3)
372
373## CURLINFO_XFER_ID
374
375The ID of the transfer. (Added in 8.2.0) See CURLINFO_XFER_ID(3)
376
377# TIMES
378
379An overview of the time values available from curl_easy_getinfo(3)
380
381    curl_easy_perform()
382        |
383        |--QUEUE
384        |--|--NAMELOOKUP
385        |--|--|--CONNECT
386        |--|--|--|--APPCONNECT
387        |--|--|--|--|--PRETRANSFER
388        |--|--|--|--|--|--POSTTRANSFER
389        |--|--|--|--|--|--|--STARTTRANSFER
390        |--|--|--|--|--|--|--|--TOTAL
391        |--|--|--|--|--|--|--|--REDIRECT
392
393
394 CURLINFO_QUEUE_TIME_T(3), CURLINFO_NAMELOOKUP_TIME_T(3),
395 CURLINFO_CONNECT_TIME_T(3), CURLINFO_APPCONNECT_TIME_T(3),
396 CURLINFO_PRETRANSFER_TIME_T(3), CURLINFO_POSTTRANSFER_TIME_T(3),
397 CURLINFO_STARTTRANSFER_TIME_T(3), CURLINFO_TOTAL_TIME_T(3),
398 CURLINFO_REDIRECT_TIME_T(3)
399
400# %PROTOCOLS%
401
402# EXAMPLE
403
404~~~c
405int main(void)
406{
407  CURL *curl = curl_easy_init();
408  if(curl) {
409    CURLcode res;
410    curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
411    res = curl_easy_perform(curl);
412
413    if(CURLE_OK == res) {
414      char *ct;
415      /* ask for the content-type */
416      res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
417
418      if((CURLE_OK == res) && ct)
419        printf("We received Content-Type: %s\n", ct);
420    }
421
422    /* always cleanup */
423    curl_easy_cleanup(curl);
424  }
425}
426~~~
427
428# %AVAILABILITY%
429
430# RETURN VALUE
431
432If the operation was successful, CURLE_OK is returned. Otherwise an
433appropriate error code is returned.
434