curl_easy_getinfo.3 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. .\" generated by cd2nroff 0.1 from curl_easy_getinfo.md
  2. .TH curl_easy_getinfo 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_easy_getinfo \- extract information from a curl handle
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
  9. .fi
  10. .SH DESCRIPTION
  11. Get the \fIinfo\fP kept in the \fIcurl\fP handle. The third argument \fBMUST\fP be
  12. pointing to the specific type of the used option which is documented in each
  13. man page of the \fIinfo\fP option. The data is stored accordingly and can be
  14. relied upon only if this function returns CURLE_OK. Use this function after a
  15. performed transfer if you want to get transfer related data.
  16. You should not free the memory returned by this function unless it is
  17. explicitly mentioned below.
  18. .SH OPTIONS
  19. The following information can be extracted:
  20. .IP CURLINFO_ACTIVESOCKET
  21. The session\(aqs active socket. See \fICURLINFO_ACTIVESOCKET(3)\fP
  22. .IP CURLINFO_APPCONNECT_TIME
  23. The time it took from the start until the SSL connect/handshake with the
  24. remote host was completed as a double in number of seconds. (Added in 7.19.0)
  25. .IP CURLINFO_APPCONNECT_TIME_T
  26. The time it took from the start until the SSL connect/handshake with the
  27. remote host was completed in number of microseconds. (Added in 7.60.0) See
  28. \fICURLINFO_APPCONNECT_TIME_T(3)\fP
  29. .IP CURLINFO_CAINFO
  30. Get the default value for \fICURLOPT_CAINFO(3)\fP. See \fICURLINFO_CAINFO(3)\fP
  31. .IP CURLINFO_CAPATH
  32. Get the default value for \fICURLOPT_CAPATH(3)\fP. See \fICURLINFO_CAPATH(3)\fP
  33. .IP CURLINFO_CERTINFO
  34. Certificate chain. See \fICURLINFO_CERTINFO(3)\fP
  35. .IP CURLINFO_CONDITION_UNMET
  36. Whether or not a time conditional was met or 304 HTTP response.
  37. See \fICURLINFO_CONDITION_UNMET(3)\fP
  38. .IP CURLINFO_CONNECT_TIME
  39. The time it took from the start until the connect to the remote host (or
  40. proxy) was completed. As a double. See \fICURLINFO_CONNECT_TIME(3)\fP
  41. .IP CURLINFO_CONNECT_TIME_T
  42. The time it took from the start until the connect to the remote host (or
  43. proxy) was completed. In microseconds. See \fICURLINFO_CONNECT_TIME_T(3)\fP.
  44. .IP CURLINFO_CONN_ID
  45. The ID of the last connection used by the transfer. (Added in 8.2.0)
  46. See \fICURLINFO_CONN_ID(3)\fP
  47. .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
  48. (\fBDeprecated\fP) Content length from the Content\-Length header.
  49. See \fICURLINFO_CONTENT_LENGTH_DOWNLOAD(3)\fP
  50. .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
  51. Content length from the Content\-Length header.
  52. See \fICURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)\fP
  53. .IP CURLINFO_CONTENT_LENGTH_UPLOAD
  54. (\fBDeprecated\fP) Upload size. See \fICURLINFO_CONTENT_LENGTH_UPLOAD(3)\fP
  55. .IP CURLINFO_CONTENT_LENGTH_UPLOAD_T
  56. Upload size. See \fICURLINFO_CONTENT_LENGTH_UPLOAD_T(3)\fP
  57. .IP CURLINFO_CONTENT_TYPE
  58. Content type from the \fIContent\-Type:\fP header. We recommend using
  59. \fIcurl_easy_header(3)\fP instead. See \fICURLINFO_CONTENT_TYPE(3)\fP
  60. .IP CURLINFO_COOKIELIST
  61. List of all known cookies. See \fICURLINFO_COOKIELIST(3)\fP
  62. .IP CURLINFO_EFFECTIVE_METHOD
  63. Last used HTTP method. See \fICURLINFO_EFFECTIVE_METHOD(3)\fP
  64. .IP CURLINFO_EFFECTIVE_URL
  65. Last used URL. See \fICURLINFO_EFFECTIVE_URL(3)\fP
  66. .IP CURLINFO_FILETIME
  67. Remote time of the retrieved document. See \fICURLINFO_FILETIME(3)\fP
  68. .IP CURLINFO_FILETIME_T
  69. Remote time of the retrieved document. See \fICURLINFO_FILETIME_T(3)\fP
  70. .IP CURLINFO_FTP_ENTRY_PATH
  71. The entry path after logging in to an FTP server. See
  72. \fICURLINFO_FTP_ENTRY_PATH(3)\fP
  73. .IP CURLINFO_HEADER_SIZE
  74. Number of bytes of all headers received. See \fICURLINFO_HEADER_SIZE(3)\fP
  75. .IP CURLINFO_HTTPAUTH_AVAIL
  76. Available HTTP authentication methods. See \fICURLINFO_HTTPAUTH_AVAIL(3)\fP
  77. .IP CURLINFO_HTTP_CONNECTCODE
  78. Last proxy CONNECT response code. See \fICURLINFO_HTTP_CONNECTCODE(3)\fP
  79. .IP CURLINFO_HTTP_VERSION
  80. The http version used in the connection. See \fICURLINFO_HTTP_VERSION(3)\fP
  81. .IP CURLINFO_LASTSOCKET
  82. (\fBDeprecated\fP) Last socket used. See \fICURLINFO_LASTSOCKET(3)\fP
  83. .IP CURLINFO_LOCAL_IP
  84. Source IP address of the last connection. See \fICURLINFO_LOCAL_IP(3)\fP
  85. .IP CURLINFO_LOCAL_PORT
  86. Source port number of the last connection. See \fICURLINFO_LOCAL_PORT(3)\fP
  87. .IP CURLINFO_NAMELOOKUP_TIME
  88. Time from start until name resolving completed as a double. See
  89. \fICURLINFO_NAMELOOKUP_TIME(3)\fP
  90. .IP CURLINFO_NAMELOOKUP_TIME_T
  91. Time from start until name resolving completed in number of microseconds. See
  92. \fICURLINFO_NAMELOOKUP_TIME_T(3)\fP
  93. .IP CURLINFO_NUM_CONNECTS
  94. Number of new successful connections used for previous transfer.
  95. See \fICURLINFO_NUM_CONNECTS(3)\fP
  96. .IP CURLINFO_OS_ERRNO
  97. The errno from the last failure to connect. See \fICURLINFO_OS_ERRNO(3)\fP
  98. .IP CURLINFO_PRETRANSFER_TIME
  99. The time it took from the start until the file transfer is just about to
  100. begin. This includes all pre\-transfer commands and negotiations that are
  101. specific to the particular protocol(s) involved. See
  102. \fICURLINFO_PRETRANSFER_TIME(3)\fP
  103. .IP CURLINFO_PRETRANSFER_TIME_T
  104. The time it took from the start until the file transfer is just about to
  105. begin. This includes all pre\-transfer commands and negotiations that are
  106. specific to the particular protocol(s) involved. In microseconds. See
  107. \fICURLINFO_PRETRANSFER_TIME_T(3)\fP
  108. .IP CURLINFO_PRIMARY_IP
  109. Destination IP address of the last connection. See \fICURLINFO_PRIMARY_IP(3)\fP
  110. .IP CURLINFO_PRIMARY_PORT
  111. Destination port of the last connection. See \fICURLINFO_PRIMARY_PORT(3)\fP
  112. .IP CURLINFO_PRIVATE
  113. User\(aqs private data pointer. See \fICURLINFO_PRIVATE(3)\fP
  114. .IP CURLINFO_PROTOCOL
  115. (\fBDeprecated\fP) The protocol used for the connection. (Added in 7.52.0) See
  116. \fICURLINFO_PROTOCOL(3)\fP
  117. .IP CURLINFO_PROXYAUTH_AVAIL
  118. Available HTTP proxy authentication methods. See \fICURLINFO_PROXYAUTH_AVAIL(3)\fP
  119. .IP CURLINFO_PROXY_ERROR
  120. Detailed proxy error. See \fICURLINFO_PROXY_ERROR(3)\fP
  121. .IP CURLINFO_PROXY_SSL_VERIFYRESULT
  122. Proxy certificate verification result. See \fICURLINFO_PROXY_SSL_VERIFYRESULT(3)\fP
  123. .IP CURLINFO_QUEUE_TIME_T
  124. The time during which the transfer was held in a waiting queue before it could
  125. start for real in number of microseconds. (Added in 8.6.0) See
  126. \fICURLINFO_QUEUE_TIME_T(3)\fP
  127. .IP CURLINFO_REDIRECT_COUNT
  128. Total number of redirects that were followed. See \fICURLINFO_REDIRECT_COUNT(3)\fP
  129. .IP CURLINFO_REDIRECT_TIME
  130. The time it took for all redirection steps include name lookup, connect,
  131. pretransfer and transfer before final transaction was started. So, this is
  132. zero if no redirection took place. As a double. See \fICURLINFO_REDIRECT_TIME(3)\fP
  133. .IP CURLINFO_REDIRECT_TIME_T
  134. The time it took for all redirection steps include name lookup, connect,
  135. pretransfer and transfer before final transaction was started. So, this is
  136. zero if no redirection took place. In number of microseconds. See
  137. \fICURLINFO_REDIRECT_TIME_T(3)\fP
  138. .IP CURLINFO_REDIRECT_URL
  139. URL a redirect would take you to, had you enabled redirects. See
  140. \fICURLINFO_REDIRECT_URL(3)\fP
  141. .IP CURLINFO_REFERER
  142. Referrer header. See \fICURLINFO_REFERER(3)\fP
  143. .IP CURLINFO_REQUEST_SIZE
  144. Number of bytes sent in the issued HTTP requests. See \fICURLINFO_REQUEST_SIZE(3)\fP
  145. .IP CURLINFO_RESPONSE_CODE
  146. Last received response code. See \fICURLINFO_RESPONSE_CODE(3)\fP
  147. .IP CURLINFO_RETRY_AFTER
  148. The value from the Retry\-After header. See \fICURLINFO_RETRY_AFTER(3)\fP
  149. .IP CURLINFO_RTSP_CLIENT_CSEQ
  150. The RTSP client CSeq that is expected next. See \fICURLINFO_RTSP_CLIENT_CSEQ(3)\fP
  151. .IP CURLINFO_RTSP_CSEQ_RECV
  152. RTSP CSeq last received. See \fICURLINFO_RTSP_CSEQ_RECV(3)\fP
  153. .IP CURLINFO_RTSP_SERVER_CSEQ
  154. The RTSP server CSeq that is expected next. See \fICURLINFO_RTSP_SERVER_CSEQ(3)\fP
  155. .IP CURLINFO_RTSP_SESSION_ID
  156. RTSP session ID. See \fICURLINFO_RTSP_SESSION_ID(3)\fP
  157. .IP CURLINFO_SCHEME
  158. The scheme used for the connection. (Added in 7.52.0) See \fICURLINFO_SCHEME(3)\fP
  159. .IP CURLINFO_SIZE_DOWNLOAD
  160. (\fBDeprecated\fP) Number of bytes downloaded. See \fICURLINFO_SIZE_DOWNLOAD(3)\fP
  161. .IP CURLINFO_SIZE_DOWNLOAD_T
  162. Number of bytes downloaded. See \fICURLINFO_SIZE_DOWNLOAD_T(3)\fP
  163. .IP CURLINFO_SIZE_UPLOAD
  164. (\fBDeprecated\fP) Number of bytes uploaded. See \fICURLINFO_SIZE_UPLOAD(3)\fP
  165. .IP CURLINFO_SIZE_UPLOAD_T
  166. Number of bytes uploaded. See \fICURLINFO_SIZE_UPLOAD_T(3)\fP
  167. .IP CURLINFO_SPEED_DOWNLOAD
  168. (\fBDeprecated\fP) Average download speed. See \fICURLINFO_SPEED_DOWNLOAD(3)\fP
  169. .IP CURLINFO_SPEED_DOWNLOAD_T
  170. Average download speed. See \fICURLINFO_SPEED_DOWNLOAD_T(3)\fP
  171. .IP CURLINFO_SPEED_UPLOAD
  172. (\fBDeprecated\fP) Average upload speed. See \fICURLINFO_SPEED_UPLOAD(3)\fP
  173. .IP CURLINFO_SPEED_UPLOAD_T
  174. Average upload speed in number of bytes per second. See
  175. \fICURLINFO_SPEED_UPLOAD_T(3)\fP
  176. .IP CURLINFO_SSL_ENGINES
  177. A list of OpenSSL crypto engines. See \fICURLINFO_SSL_ENGINES(3)\fP
  178. .IP CURLINFO_SSL_VERIFYRESULT
  179. Certificate verification result. See \fICURLINFO_SSL_VERIFYRESULT(3)\fP
  180. .IP CURLINFO_STARTTRANSFER_TIME
  181. The time it took from the start until the first byte is received by libcurl.
  182. As a double. See \fICURLINFO_STARTTRANSFER_TIME(3)\fP
  183. .IP CURLINFO_STARTTRANSFER_TIME_T
  184. The time it took from the start until the first byte is received by libcurl.
  185. In microseconds. See \fICURLINFO_STARTTRANSFER_TIME_T(3)\fP
  186. .IP CURLINFO_TLS_SESSION
  187. (\fBDeprecated\fP) TLS session info that can be used for further processing. See
  188. \fICURLINFO_TLS_SESSION(3)\fP. Use \fICURLINFO_TLS_SSL_PTR(3)\fP instead!
  189. .IP CURLINFO_TLS_SSL_PTR
  190. TLS session info that can be used for further processing. See
  191. \fICURLINFO_TLS_SSL_PTR(3)\fP
  192. .IP CURLINFO_TOTAL_TIME
  193. Total time of previous transfer. See \fICURLINFO_TOTAL_TIME(3)\fP
  194. .IP CURLINFO_TOTAL_TIME_T
  195. Total time of previous transfer. See \fICURLINFO_TOTAL_TIME_T(3)\fP
  196. .IP CURLINFO_USED_PROXY
  197. Whether the proxy was used (Added in 8.7.0). See \fICURLINFO_USED_PROXY(3)\fP
  198. .IP CURLINFO_XFER_ID
  199. The ID of the transfer. (Added in 8.2.0) See \fICURLINFO_XFER_ID(3)\fP
  200. .SH TIMES
  201. An overview of the time values available from \fIcurl_easy_getinfo(3)\fP
  202. .nf
  203. curl_easy_perform()
  204. |
  205. |--QUEUE
  206. |--|--NAMELOOKUP
  207. |--|--|--CONNECT
  208. |--|--|--|--APPCONNECT
  209. |--|--|--|--|--PRETRANSFER
  210. |--|--|--|--|--|--STARTTRANSFER
  211. |--|--|--|--|--|--|--TOTAL
  212. |--|--|--|--|--|--|--REDIRECT
  213. .fi
  214. \fICURLINFO_QUEUE_TIME_T(3)\fP, \fICURLINFO_NAMELOOKUP_TIME_T(3)\fP,
  215. \fICURLINFO_CONNECT_TIME_T(3)\fP, \fICURLINFO_APPCONNECT_TIME_T(3)\fP,
  216. \fICURLINFO_PRETRANSFER_TIME_T(3)\fP, \fICURLINFO_STARTTRANSFER_TIME_T(3)\fP,
  217. \fICURLINFO_TOTAL_TIME_T(3)\fP, \fICURLINFO_REDIRECT_TIME_T(3)\fP
  218. .SH PROTOCOLS
  219. This functionality affects all supported protocols
  220. .SH EXAMPLE
  221. .nf
  222. int main(void)
  223. {
  224. CURL *curl = curl_easy_init();
  225. if(curl) {
  226. CURLcode res;
  227. curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
  228. res = curl_easy_perform(curl);
  229. if(CURLE_OK == res) {
  230. char *ct;
  231. /* ask for the content-type */
  232. res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
  233. if((CURLE_OK == res) && ct)
  234. printf("We received Content-Type: %s\\n", ct);
  235. }
  236. /* always cleanup */
  237. curl_easy_cleanup(curl);
  238. }
  239. }
  240. .fi
  241. .SH AVAILABILITY
  242. Added in curl 7.4.1
  243. .SH RETURN VALUE
  244. If the operation was successful, CURLE_OK is returned. Otherwise an
  245. appropriate error code is returned.
  246. .SH SEE ALSO
  247. .BR curl_easy_setopt (3)