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