curl_easy_getinfo.3 11 KB

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