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_HTTPAUTH_USED 150 151Used HTTP authentication method. See CURLINFO_HTTPAUTH_USED(3) 152 153## CURLINFO_HTTP_CONNECTCODE 154 155Last proxy CONNECT response code. See CURLINFO_HTTP_CONNECTCODE(3) 156 157## CURLINFO_HTTP_VERSION 158 159The http version used in the connection. See CURLINFO_HTTP_VERSION(3) 160 161## CURLINFO_LASTSOCKET 162 163(**Deprecated**) Last socket used. See CURLINFO_LASTSOCKET(3) 164 165## CURLINFO_LOCAL_IP 166 167Source IP address of the last connection. See CURLINFO_LOCAL_IP(3) 168 169## CURLINFO_LOCAL_PORT 170 171Source port number of the last connection. See CURLINFO_LOCAL_PORT(3) 172 173## CURLINFO_NAMELOOKUP_TIME 174 175Time from start until name resolving completed as a double. See 176CURLINFO_NAMELOOKUP_TIME(3) 177 178## CURLINFO_NAMELOOKUP_TIME_T 179 180Time from start until name resolving completed in number of microseconds. See 181CURLINFO_NAMELOOKUP_TIME_T(3) 182 183## CURLINFO_NUM_CONNECTS 184 185Number of new successful connections used for previous transfer. 186See CURLINFO_NUM_CONNECTS(3) 187 188## CURLINFO_OS_ERRNO 189 190The errno from the last failure to connect. See CURLINFO_OS_ERRNO(3) 191 192## CURLINFO_POSTTRANSFER_TIME_T 193 194The time it took from the start until the last byte is sent by libcurl. 195In microseconds. (Added in 8.10.0) See CURLINFO_POSTTRANSFER_TIME_T(3) 196 197## CURLINFO_PRETRANSFER_TIME 198 199The time it took from the start until the file transfer is just about to 200begin. This includes all pre-transfer commands and negotiations that are 201specific to the particular protocol(s) involved. See 202CURLINFO_PRETRANSFER_TIME(3) 203 204## CURLINFO_PRETRANSFER_TIME_T 205 206The time it took from the start until the file transfer is just about to 207begin. This includes all pre-transfer commands and negotiations that are 208specific to the particular protocol(s) involved. In microseconds. See 209CURLINFO_PRETRANSFER_TIME_T(3) 210 211## CURLINFO_PRIMARY_IP 212 213Destination IP address of the last connection. See CURLINFO_PRIMARY_IP(3) 214 215## CURLINFO_PRIMARY_PORT 216 217Destination port of the last connection. See CURLINFO_PRIMARY_PORT(3) 218 219## CURLINFO_PRIVATE 220 221User's private data pointer. See CURLINFO_PRIVATE(3) 222 223## CURLINFO_PROTOCOL 224 225(**Deprecated**) The protocol used for the connection. (Added in 7.52.0) See 226CURLINFO_PROTOCOL(3) 227 228## CURLINFO_PROXYAUTH_AVAIL 229 230Available HTTP proxy authentication methods. See CURLINFO_PROXYAUTH_AVAIL(3) 231 232## CURLINFO_PROXYAUTH_USED 233 234Used HTTP proxy authentication methods. See CURLINFO_PROXYAUTH_USED(3) 235 236## CURLINFO_PROXY_ERROR 237 238Detailed proxy error. See CURLINFO_PROXY_ERROR(3) 239 240## CURLINFO_PROXY_SSL_VERIFYRESULT 241 242Proxy certificate verification result. See CURLINFO_PROXY_SSL_VERIFYRESULT(3) 243 244## CURLINFO_QUEUE_TIME_T 245 246The time during which the transfer was held in a waiting queue before it could 247start for real in number of microseconds. (Added in 8.6.0) See 248CURLINFO_QUEUE_TIME_T(3) 249 250## CURLINFO_REDIRECT_COUNT 251 252Total number of redirects that were followed. See CURLINFO_REDIRECT_COUNT(3) 253 254## CURLINFO_REDIRECT_TIME 255 256The time it took for all redirection steps include name lookup, connect, 257pretransfer and transfer before final transaction was started. So, this is 258zero if no redirection took place. As a double. See CURLINFO_REDIRECT_TIME(3) 259 260## CURLINFO_REDIRECT_TIME_T 261 262The time it took for all redirection steps include name lookup, connect, 263pretransfer and transfer before final transaction was started. So, this is 264zero if no redirection took place. In number of microseconds. See 265CURLINFO_REDIRECT_TIME_T(3) 266 267## CURLINFO_REDIRECT_URL 268 269URL a redirect would take you to, had you enabled redirects. See 270CURLINFO_REDIRECT_URL(3) 271 272## CURLINFO_REFERER 273 274Referrer header. See CURLINFO_REFERER(3) 275 276## CURLINFO_REQUEST_SIZE 277 278Number of bytes sent in the issued HTTP requests. See CURLINFO_REQUEST_SIZE(3) 279 280## CURLINFO_RESPONSE_CODE 281 282Last received response code. See CURLINFO_RESPONSE_CODE(3) 283 284## CURLINFO_RETRY_AFTER 285 286The value from the Retry-After header. See CURLINFO_RETRY_AFTER(3) 287 288## CURLINFO_RTSP_CLIENT_CSEQ 289 290The RTSP client CSeq that is expected next. See CURLINFO_RTSP_CLIENT_CSEQ(3) 291 292## CURLINFO_RTSP_CSEQ_RECV 293 294RTSP CSeq last received. See CURLINFO_RTSP_CSEQ_RECV(3) 295 296## CURLINFO_RTSP_SERVER_CSEQ 297 298The RTSP server CSeq that is expected next. See CURLINFO_RTSP_SERVER_CSEQ(3) 299 300## CURLINFO_RTSP_SESSION_ID 301 302RTSP session ID. See CURLINFO_RTSP_SESSION_ID(3) 303 304## CURLINFO_SCHEME 305 306The scheme used for the connection. (Added in 7.52.0) See CURLINFO_SCHEME(3) 307 308## CURLINFO_SIZE_DOWNLOAD 309 310(**Deprecated**) Number of bytes downloaded. See CURLINFO_SIZE_DOWNLOAD(3) 311 312## CURLINFO_SIZE_DOWNLOAD_T 313 314Number of bytes downloaded. See CURLINFO_SIZE_DOWNLOAD_T(3) 315 316## CURLINFO_SIZE_UPLOAD 317 318(**Deprecated**) Number of bytes uploaded. See CURLINFO_SIZE_UPLOAD(3) 319 320## CURLINFO_SIZE_UPLOAD_T 321 322Number of bytes uploaded. See CURLINFO_SIZE_UPLOAD_T(3) 323 324## CURLINFO_SPEED_DOWNLOAD 325 326(**Deprecated**) Average download speed. See CURLINFO_SPEED_DOWNLOAD(3) 327 328## CURLINFO_SPEED_DOWNLOAD_T 329 330Average download speed. See CURLINFO_SPEED_DOWNLOAD_T(3) 331 332## CURLINFO_SPEED_UPLOAD 333 334(**Deprecated**) Average upload speed. See CURLINFO_SPEED_UPLOAD(3) 335 336## CURLINFO_SPEED_UPLOAD_T 337 338Average upload speed in number of bytes per second. See 339CURLINFO_SPEED_UPLOAD_T(3) 340 341## CURLINFO_SSL_ENGINES 342 343A list of OpenSSL crypto engines. See CURLINFO_SSL_ENGINES(3) 344 345## CURLINFO_SSL_VERIFYRESULT 346 347Certificate verification result. See CURLINFO_SSL_VERIFYRESULT(3) 348 349## CURLINFO_STARTTRANSFER_TIME 350 351The time it took from the start until the first byte is received by libcurl. 352As a double. See CURLINFO_STARTTRANSFER_TIME(3) 353 354## CURLINFO_STARTTRANSFER_TIME_T 355 356The time it took from the start until the first byte is received by libcurl. 357In microseconds. See CURLINFO_STARTTRANSFER_TIME_T(3) 358 359## CURLINFO_TLS_SESSION 360 361(**Deprecated**) TLS session info that can be used for further processing. See 362CURLINFO_TLS_SESSION(3). Use CURLINFO_TLS_SSL_PTR(3) instead. 363 364## CURLINFO_TLS_SSL_PTR 365 366TLS session info that can be used for further processing. See 367CURLINFO_TLS_SSL_PTR(3) 368 369## CURLINFO_TOTAL_TIME 370 371Total time of previous transfer. See CURLINFO_TOTAL_TIME(3) 372 373## CURLINFO_TOTAL_TIME_T 374 375Total time of previous transfer. See CURLINFO_TOTAL_TIME_T(3) 376 377## CURLINFO_USED_PROXY 378 379Whether the proxy was used (Added in 8.7.0). See CURLINFO_USED_PROXY(3) 380 381## CURLINFO_XFER_ID 382 383The ID of the transfer. (Added in 8.2.0) See CURLINFO_XFER_ID(3) 384 385# TIMES 386 387An overview of the time values available from curl_easy_getinfo(3) 388 389 curl_easy_perform() 390 | 391 |--QUEUE 392 |--|--NAMELOOKUP 393 |--|--|--CONNECT 394 |--|--|--|--APPCONNECT 395 |--|--|--|--|--PRETRANSFER 396 |--|--|--|--|--|--POSTTRANSFER 397 |--|--|--|--|--|--|--STARTTRANSFER 398 |--|--|--|--|--|--|--|--TOTAL 399 |--|--|--|--|--|--|--|--REDIRECT 400 401 402 CURLINFO_QUEUE_TIME_T(3), CURLINFO_NAMELOOKUP_TIME_T(3), 403 CURLINFO_CONNECT_TIME_T(3), CURLINFO_APPCONNECT_TIME_T(3), 404 CURLINFO_PRETRANSFER_TIME_T(3), CURLINFO_POSTTRANSFER_TIME_T(3), 405 CURLINFO_STARTTRANSFER_TIME_T(3), CURLINFO_TOTAL_TIME_T(3), 406 CURLINFO_REDIRECT_TIME_T(3) 407 408# %PROTOCOLS% 409 410# EXAMPLE 411 412~~~c 413int main(void) 414{ 415 CURL *curl = curl_easy_init(); 416 if(curl) { 417 CURLcode res; 418 curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/"); 419 res = curl_easy_perform(curl); 420 421 if(CURLE_OK == res) { 422 char *ct; 423 /* ask for the content-type */ 424 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); 425 426 if((CURLE_OK == res) && ct) 427 printf("We received Content-Type: %s\n", ct); 428 } 429 430 /* always cleanup */ 431 curl_easy_cleanup(curl); 432 } 433} 434~~~ 435 436# %AVAILABILITY% 437 438# RETURN VALUE 439 440This function returns a CURLcode indicating success or error. 441 442CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 443libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) 444there can be an error message stored in the error buffer when non-zero is 445returned. 446