curl_easy_getinfo.3 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH curl_easy_getinfo 3 "11 Feb 2009" "libcurl" "libcurl"
  26. .SH NAME
  27. curl_easy_getinfo - extract information from a curl handle
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
  32. .fi
  33. .SH DESCRIPTION
  34. Request internal information from the curl session with this function. The
  35. third argument \fBMUST\fP be pointing to the specific type of the used option
  36. which is documented in each man page of the option. The data pointed-to will
  37. be filled in accordingly and can be relied upon only if the function returns
  38. CURLE_OK. Use this function AFTER a performed transfer if you want to get
  39. transfer related data.
  40. You should not free the memory returned by this function unless it is
  41. explicitly mentioned below.
  42. .SH AVAILABLE INFORMATION
  43. The following information can be extracted:
  44. .IP CURLINFO_EFFECTIVE_METHOD
  45. Last used HTTP method.
  46. See \fICURLINFO_EFFECTIVE_METHOD(3)\fP
  47. .IP CURLINFO_EFFECTIVE_URL
  48. Last used URL.
  49. See \fICURLINFO_EFFECTIVE_URL(3)\fP
  50. .IP CURLINFO_RESPONSE_CODE
  51. Last received response code.
  52. See \fICURLINFO_RESPONSE_CODE(3)\fP
  53. .IP CURLINFO_REFERER
  54. Referrer header.
  55. See \fICURLINFO_REFERER(3)\fP
  56. .IP CURLINFO_HTTP_CONNECTCODE
  57. Last proxy CONNECT response code.
  58. See \fICURLINFO_HTTP_CONNECTCODE(3)\fP
  59. .IP CURLINFO_HTTP_VERSION
  60. The http version used in the connection.
  61. See \fICURLINFO_HTTP_VERSION(3)\fP
  62. .IP CURLINFO_FILETIME
  63. Remote time of the retrieved document. See \fICURLINFO_FILETIME(3)\fP
  64. .IP CURLINFO_FILETIME_T
  65. Remote time of the retrieved document. See \fICURLINFO_FILETIME_T(3)\fP
  66. .IP CURLINFO_TOTAL_TIME
  67. Total time of previous transfer.
  68. See \fICURLINFO_TOTAL_TIME(3)\fP
  69. .IP CURLINFO_TOTAL_TIME_T
  70. Total time of previous transfer.
  71. See \fICURLINFO_TOTAL_TIME_T(3)\fP
  72. .IP CURLINFO_NAMELOOKUP_TIME
  73. Time from start until name resolving completed.
  74. See \fICURLINFO_NAMELOOKUP_TIME(3)\fP
  75. .IP CURLINFO_NAMELOOKUP_TIME_T
  76. Time from start until name resolving completed.
  77. See \fICURLINFO_NAMELOOKUP_TIME_T(3)\fP
  78. .IP CURLINFO_CONNECT_TIME
  79. Time from start until remote host or proxy completed.
  80. See \fICURLINFO_CONNECT_TIME(3)\fP
  81. .IP CURLINFO_CONNECT_TIME_T
  82. Time from start until remote host or proxy completed.
  83. See \fICURLINFO_CONNECT_TIME_T(3)\fP
  84. .IP CURLINFO_APPCONNECT_TIME
  85. Time from start until SSL/SSH handshake completed.
  86. See \fICURLINFO_APPCONNECT_TIME(3)\fP
  87. .IP CURLINFO_APPCONNECT_TIME_T
  88. Time from start until SSL/SSH handshake completed.
  89. See \fICURLINFO_APPCONNECT_TIME_T(3)\fP
  90. .IP CURLINFO_PRETRANSFER_TIME
  91. Time from start until just before the transfer begins.
  92. See \fICURLINFO_PRETRANSFER_TIME(3)\fP
  93. .IP CURLINFO_PRETRANSFER_TIME_T
  94. Time from start until just before the transfer begins.
  95. See \fICURLINFO_PRETRANSFER_TIME_T(3)\fP
  96. .IP CURLINFO_STARTTRANSFER_TIME
  97. Time from start until just when the first byte is received.
  98. See \fICURLINFO_STARTTRANSFER_TIME(3)\fP
  99. .IP CURLINFO_STARTTRANSFER_TIME_T
  100. Time from start until just when the first byte is received.
  101. See \fICURLINFO_STARTTRANSFER_TIME_T(3)\fP
  102. .IP CURLINFO_REDIRECT_TIME
  103. Time taken for all redirect steps before the final transfer.
  104. See \fICURLINFO_REDIRECT_TIME(3)\fP
  105. .IP CURLINFO_REDIRECT_TIME_T
  106. Time taken for all redirect steps before the final transfer.
  107. See \fICURLINFO_REDIRECT_TIME_T(3)\fP
  108. .IP CURLINFO_REDIRECT_COUNT
  109. Total number of redirects that were followed.
  110. See \fICURLINFO_REDIRECT_COUNT(3)\fP
  111. .IP CURLINFO_REDIRECT_URL
  112. URL a redirect would take you to, had you enabled redirects.
  113. See \fICURLINFO_REDIRECT_URL(3)\fP
  114. .IP CURLINFO_SIZE_UPLOAD
  115. (Deprecated) Number of bytes uploaded.
  116. See \fICURLINFO_SIZE_UPLOAD(3)\fP
  117. .IP CURLINFO_SIZE_UPLOAD_T
  118. Number of bytes uploaded.
  119. See \fICURLINFO_SIZE_UPLOAD_T(3)\fP
  120. .IP CURLINFO_SIZE_DOWNLOAD
  121. (Deprecated) Number of bytes downloaded.
  122. See \fICURLINFO_SIZE_DOWNLOAD(3)\fP
  123. .IP CURLINFO_SIZE_DOWNLOAD_T
  124. Number of bytes downloaded.
  125. See \fICURLINFO_SIZE_DOWNLOAD_T(3)\fP
  126. .IP CURLINFO_SPEED_DOWNLOAD
  127. (Deprecated) Average download speed.
  128. See \fICURLINFO_SPEED_DOWNLOAD(3)\fP
  129. .IP CURLINFO_SPEED_DOWNLOAD_T
  130. Average download speed.
  131. See \fICURLINFO_SPEED_DOWNLOAD_T(3)\fP
  132. .IP CURLINFO_SPEED_UPLOAD
  133. (Deprecated) Average upload speed.
  134. See \fICURLINFO_SPEED_UPLOAD(3)\fP
  135. .IP CURLINFO_SPEED_UPLOAD_T
  136. Average upload speed.
  137. See \fICURLINFO_SPEED_UPLOAD_T(3)\fP
  138. .IP CURLINFO_HEADER_SIZE
  139. Number of bytes of all headers received.
  140. See \fICURLINFO_HEADER_SIZE(3)\fP
  141. .IP CURLINFO_REQUEST_SIZE
  142. Number of bytes sent in the issued HTTP requests.
  143. See \fICURLINFO_REQUEST_SIZE(3)\fP
  144. .IP CURLINFO_SSL_VERIFYRESULT
  145. Certificate verification result.
  146. See \fICURLINFO_SSL_VERIFYRESULT(3)\fP
  147. .IP CURLINFO_PROXY_ERROR
  148. Detailed proxy error.
  149. See \fICURLINFO_PROXY_ERROR(3)\fP
  150. .IP CURLINFO_PROXY_SSL_VERIFYRESULT
  151. Proxy certificate verification result.
  152. See \fICURLINFO_PROXY_SSL_VERIFYRESULT(3)\fP
  153. .IP CURLINFO_SSL_ENGINES
  154. A list of OpenSSL crypto engines.
  155. See \fICURLINFO_SSL_ENGINES(3)\fP
  156. .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
  157. (Deprecated) Content length from the Content-Length header.
  158. See \fICURLINFO_CONTENT_LENGTH_DOWNLOAD(3)\fP
  159. .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
  160. Content length from the Content-Length header.
  161. See \fICURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)\fP
  162. .IP CURLINFO_CONTENT_LENGTH_UPLOAD
  163. (Deprecated) Upload size. See \fICURLINFO_CONTENT_LENGTH_UPLOAD(3)\fP
  164. .IP CURLINFO_CONTENT_LENGTH_UPLOAD_T
  165. Upload size. See \fICURLINFO_CONTENT_LENGTH_UPLOAD_T(3)\fP
  166. .IP CURLINFO_CONTENT_TYPE
  167. Content type from the Content-Type header.
  168. See \fICURLINFO_CONTENT_TYPE(3)\fP
  169. .IP CURLINFO_RETRY_AFTER
  170. The value from the Retry-After header.
  171. See \fICURLINFO_RETRY_AFTER(3)\fP
  172. .IP CURLINFO_PRIVATE
  173. User's private data pointer.
  174. See \fICURLINFO_PRIVATE(3)\fP
  175. .IP CURLINFO_HTTPAUTH_AVAIL
  176. Available HTTP authentication methods.
  177. See \fICURLINFO_HTTPAUTH_AVAIL(3)\fP
  178. .IP CURLINFO_PROXYAUTH_AVAIL
  179. Available HTTP proxy authentication methods.
  180. See \fICURLINFO_PROXYAUTH_AVAIL(3)\fP
  181. .IP CURLINFO_OS_ERRNO
  182. The errno from the last failure to connect.
  183. See \fICURLINFO_OS_ERRNO(3)\fP
  184. .IP CURLINFO_NUM_CONNECTS
  185. Number of new successful connections used for previous transfer.
  186. See \fICURLINFO_NUM_CONNECTS(3)\fP
  187. .IP CURLINFO_PRIMARY_IP
  188. IP address of the last connection.
  189. See \fICURLINFO_PRIMARY_IP(3)\fP
  190. .IP CURLINFO_PRIMARY_PORT
  191. Port of the last connection.
  192. See \fICURLINFO_PRIMARY_PORT(3)\fP
  193. .IP CURLINFO_LOCAL_IP
  194. Local-end IP address of last connection.
  195. See \fICURLINFO_LOCAL_IP(3)\fP
  196. .IP CURLINFO_LOCAL_PORT
  197. Local-end port of last connection.
  198. See \fICURLINFO_LOCAL_PORT(3)\fP
  199. .IP CURLINFO_COOKIELIST
  200. List of all known cookies.
  201. See \fICURLINFO_COOKIELIST(3)\fP
  202. .IP CURLINFO_LASTSOCKET
  203. (Deprecated) Last socket used.
  204. See \fICURLINFO_LASTSOCKET(3)\fP
  205. .IP CURLINFO_ACTIVESOCKET
  206. The session's active socket.
  207. See \fICURLINFO_ACTIVESOCKET(3)\fP
  208. .IP CURLINFO_FTP_ENTRY_PATH
  209. The entry path after logging in to an FTP server.
  210. See \fICURLINFO_FTP_ENTRY_PATH(3)\fP
  211. .IP CURLINFO_CAPATH
  212. Get the default value for \fICURLOPT_CAPATH(3)\fP.
  213. See \fICURLINFO_CAPATH(3)\fP
  214. .IP CURLINFO_CAINFO
  215. Get the default value for \fICURLOPT_CAINFO(3)\fP.
  216. See \fICURLINFO_CAINFO(3)\fP
  217. .IP CURLINFO_CERTINFO
  218. Certificate chain.
  219. See \fICURLINFO_CERTINFO(3)\fP
  220. .IP CURLINFO_TLS_SSL_PTR
  221. TLS session info that can be used for further processing.
  222. See \fICURLINFO_TLS_SSL_PTR(3)\fP
  223. .IP CURLINFO_TLS_SESSION
  224. TLS session info that can be used for further processing. See
  225. \fICURLINFO_TLS_SESSION(3)\fP. Deprecated option, use
  226. \fICURLINFO_TLS_SSL_PTR(3)\fP instead!
  227. .IP CURLINFO_CONDITION_UNMET
  228. Whether or not a time conditional was met or 304 HTTP response.
  229. See \fICURLINFO_CONDITION_UNMET(3)\fP
  230. .IP CURLINFO_RTSP_SESSION_ID
  231. RTSP session ID.
  232. See \fICURLINFO_RTSP_SESSION_ID(3)\fP
  233. .IP CURLINFO_RTSP_CLIENT_CSEQ
  234. RTSP CSeq that will next be used.
  235. See \fICURLINFO_RTSP_CLIENT_CSEQ(3)\fP
  236. .IP CURLINFO_RTSP_SERVER_CSEQ
  237. RTSP CSeq that will next be expected.
  238. See \fICURLINFO_RTSP_SERVER_CSEQ(3)\fP
  239. .IP CURLINFO_RTSP_CSEQ_RECV
  240. RTSP CSeq last received.
  241. See \fICURLINFO_RTSP_CSEQ_RECV(3)\fP
  242. .IP CURLINFO_PROTOCOL
  243. (Deprecated) The protocol used for the connection. (Added in 7.52.0)
  244. See \fICURLINFO_PROTOCOL(3)\fP
  245. .IP CURLINFO_SCHEME
  246. The scheme used for the connection. (Added in 7.52.0)
  247. See \fICURLINFO_SCHEME(3)\fP
  248. .IP CURLINFO_CONN_ID
  249. The ID of the last connection used by the transfer. (Added in 8.2.0)
  250. See \fICURLINFO_CONN_ID(3)\fP
  251. .IP CURLINFO_XFER_ID
  252. The ID of the transfer. (Added in 8.2.0)
  253. See \fICURLINFO_XFER_ID(3)\fP
  254. .SH TIMES
  255. .nf
  256. An overview of the six time values available from curl_easy_getinfo()
  257. curl_easy_perform()
  258. |
  259. |--NAMELOOKUP
  260. |--|--CONNECT
  261. |--|--|--APPCONNECT
  262. |--|--|--|--PRETRANSFER
  263. |--|--|--|--|--STARTTRANSFER
  264. |--|--|--|--|--|--TOTAL
  265. |--|--|--|--|--|--REDIRECT
  266. .fi
  267. .IP NAMELOOKUP
  268. \fICURLINFO_NAMELOOKUP_TIME\fP and \fICURLINFO_NAMELOOKUP_TIME_T\fP.
  269. The time it took from the start until the name resolving was completed.
  270. .IP CONNECT
  271. \fICURLINFO_CONNECT_TIME\fP and \fICURLINFO_CONNECT_TIME_T\fP.
  272. The time it took from the start until the connect
  273. to the remote host (or proxy) was completed.
  274. .IP APPCONNECT
  275. \fICURLINFO_APPCONNECT_TIME\fP and \fICURLINFO_APPCONNECT_TIME_T\fP.
  276. The time it took from the start until the SSL
  277. connect/handshake with the remote host was completed. (Added in 7.19.0)
  278. The latter is the integer version (measuring microseconds). (Added in 7.60.0)
  279. .IP PRETRANSFER
  280. \fICURLINFO_PRETRANSFER_TIME\fP and \fICURLINFO_PRETRANSFER_TIME_T\fP.
  281. The time it took from the start until the
  282. file transfer is just about to begin. This includes all pre-transfer commands
  283. and negotiations that are specific to the particular protocol(s) involved.
  284. .IP STARTTRANSFER
  285. \fICURLINFO_STARTTRANSFER_TIME\fP and \fICURLINFO_STARTTRANSFER_TIME_T\fP.
  286. The time it took from the start until the
  287. first byte is received by libcurl.
  288. .IP TOTAL
  289. \fICURLINFO_TOTAL_TIME\fP and \fICURLINFO_TOTAL_TIME_T\fP.
  290. Total time of the previous request.
  291. .IP REDIRECT
  292. \fICURLINFO_REDIRECT_TIME\fP and \fICURLINFO_REDIRECT_TIME_T\fP.
  293. The time it took for all redirection steps
  294. include name lookup, connect, pretransfer and transfer before final
  295. transaction was started. So, this is zero if no redirection took place.
  296. .SH EXAMPLE
  297. .nf
  298. curl = curl_easy_init();
  299. if(curl) {
  300. curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
  301. res = curl_easy_perform(curl);
  302. if(CURLE_OK == res) {
  303. char *ct;
  304. /* ask for the content-type */
  305. res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
  306. if((CURLE_OK == res) && ct)
  307. printf("We received Content-Type: %s\\n", ct);
  308. }
  309. /* always cleanup */
  310. curl_easy_cleanup(curl);
  311. }
  312. .fi
  313. .SH AVAILABILITY
  314. Added in 7.4.1
  315. .SH RETURN VALUE
  316. If the operation was successful, CURLE_OK is returned. Otherwise an
  317. appropriate error code will be returned.
  318. .SH "SEE ALSO"
  319. .BR curl_easy_setopt "(3)"