curl_easy_getinfo.3 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2010, 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 http://curl.haxx.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. .\" * $Id$
  22. .\" **************************************************************************
  23. .\"
  24. .TH curl_easy_getinfo 3 "11 Feb 2009" "libcurl 7.19.4" "libcurl Manual"
  25. .SH NAME
  26. curl_easy_getinfo - extract information from a curl handle
  27. .SH SYNOPSIS
  28. .B #include <curl/curl.h>
  29. .B "CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );"
  30. .SH DESCRIPTION
  31. Request internal information from the curl session with this function. The
  32. third argument \fBMUST\fP be a pointer to a long, a pointer to a char *, a
  33. pointer to a struct curl_slist * or a pointer to a double (as this
  34. documentation describes further down). The data pointed-to will be filled in
  35. accordingly and can be relied upon only if the function returns CURLE_OK. Use
  36. this function AFTER a performed transfer if you want to get transfer- oriented
  37. data.
  38. You should not free the memory returned by this function unless it is
  39. explicitly mentioned below.
  40. .SH AVAILABLE INFORMATION
  41. The following information can be extracted:
  42. .IP CURLINFO_EFFECTIVE_URL
  43. Pass a pointer to a char pointer to receive the last used effective URL.
  44. .IP CURLINFO_RESPONSE_CODE
  45. Pass a pointer to a long to receive the last received HTTP or FTP code. This
  46. option was known as CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. This
  47. will be zero if no server response code has been received. Note that a proxy's
  48. CONNECT response should be read with \fICURLINFO_HTTP_CONNECTCODE\fP and not
  49. this.
  50. .IP CURLINFO_HTTP_CONNECTCODE
  51. Pass a pointer to a long to receive the last received proxy response code to a
  52. CONNECT request.
  53. .IP CURLINFO_FILETIME
  54. Pass a pointer to a long to receive the remote time of the retrieved document
  55. (in number of seconds since 1 jan 1970 in the GMT/UTC time zone). If you get
  56. -1, it can be because of many reasons (unknown, the server hides it or the
  57. server doesn't support the command that tells document time etc) and the time
  58. of the document is unknown. Note that you must tell the server to collect this
  59. information before the transfer is made, by using the CURLOPT_FILETIME option
  60. to \fIcurl_easy_setopt(3)\fP or you will unconditionally get a -1 back. (Added
  61. in 7.5)
  62. .IP CURLINFO_TOTAL_TIME
  63. Pass a pointer to a double to receive the total time in seconds for the
  64. previous transfer, including name resolving, TCP connect etc.
  65. .IP CURLINFO_NAMELOOKUP_TIME
  66. Pass a pointer to a double to receive the time, in seconds, it took from the
  67. start until the name resolving was completed.
  68. .IP CURLINFO_CONNECT_TIME
  69. Pass a pointer to a double to receive the time, in seconds, it took from the
  70. start until the connect to the remote host (or proxy) was completed.
  71. .IP CURLINFO_APPCONNECT_TIME
  72. Pass a pointer to a double to receive the time, in seconds, it took from the
  73. start until the SSL/SSH connect/handshake to the remote host was completed.
  74. This time is most often very near to the PRETRANSFER time, except for cases
  75. such as HTTP pippelining where the pretransfer time can be delayed due to
  76. waits in line for the pipeline and more. (Added in 7.19.0)
  77. .IP CURLINFO_PRETRANSFER_TIME
  78. Pass a pointer to a double to receive the time, in seconds, it took from the
  79. start until the file transfer is just about to begin. This includes all
  80. pre-transfer commands and negotiations that are specific to the particular
  81. protocol(s) involved.
  82. .IP CURLINFO_STARTTRANSFER_TIME
  83. Pass a pointer to a double to receive the time, in seconds, it took from the
  84. start until the first byte is just about to be transferred. This includes
  85. CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate
  86. the result.
  87. .IP CURLINFO_REDIRECT_TIME
  88. Pass a pointer to a double to receive the total time, in seconds, it took for
  89. all redirection steps include name lookup, connect, pretransfer and transfer
  90. before final transaction was started. CURLINFO_REDIRECT_TIME contains the
  91. complete execution time for multiple redirections. (Added in 7.9.7)
  92. .IP CURLINFO_REDIRECT_COUNT
  93. Pass a pointer to a long to receive the total number of redirections that were
  94. actually followed. (Added in 7.9.7)
  95. .IP CURLINFO_REDIRECT_URL
  96. Pass a pointer to a char pointer to receive the URL a redirect \fIwould\fP
  97. take you to if you would enable CURLOPT_FOLLOWLOCATION. This can come very
  98. handy if you think using the built-in libcurl redirect logic isn't good enough
  99. for you but you would still prefer to avoid implementing all the magic of
  100. figuring out the new URL. (Added in 7.18.2)
  101. .IP CURLINFO_SIZE_UPLOAD
  102. Pass a pointer to a double to receive the total amount of bytes that were
  103. uploaded.
  104. .IP CURLINFO_SIZE_DOWNLOAD
  105. Pass a pointer to a double to receive the total amount of bytes that were
  106. downloaded. The amount is only for the latest transfer and will be reset again
  107. for each new transfer.
  108. .IP CURLINFO_SPEED_DOWNLOAD
  109. Pass a pointer to a double to receive the average download speed that curl
  110. measured for the complete download. Measured in bytes/second.
  111. .IP CURLINFO_SPEED_UPLOAD
  112. Pass a pointer to a double to receive the average upload speed that curl
  113. measured for the complete upload. Measured in bytes/second.
  114. .IP CURLINFO_HEADER_SIZE
  115. Pass a pointer to a long to receive the total size of all the headers
  116. received. Measured in number of bytes.
  117. .IP CURLINFO_REQUEST_SIZE
  118. Pass a pointer to a long to receive the total size of the issued
  119. requests. This is so far only for HTTP requests. Note that this may be more
  120. than one request if FOLLOWLOCATION is true.
  121. .IP CURLINFO_SSL_VERIFYRESULT
  122. Pass a pointer to a long to receive the result of the certification
  123. verification that was requested (using the CURLOPT_SSL_VERIFYPEER option to
  124. \fIcurl_easy_setopt(3)\fP).
  125. .IP CURLINFO_SSL_ENGINES
  126. Pass the address of a 'struct curl_slist *' to receive a linked-list of
  127. OpenSSL crypto-engines supported. Note that engines are normally implemented
  128. in separate dynamic libraries. Hence not all the returned engines may be
  129. available at run-time. \fBNOTE:\fP you must call \fIcurl_slist_free_all(3)\fP
  130. on the list pointer once you're done with it, as libcurl will not free the
  131. data for you. (Added in 7.12.3)
  132. .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
  133. Pass a pointer to a double to receive the content-length of the download. This
  134. is the value read from the Content-Length: field. Since 7.19.4, this returns -1
  135. if the size isn't known.
  136. .IP CURLINFO_CONTENT_LENGTH_UPLOAD
  137. Pass a pointer to a double to receive the specified size of the upload. Since
  138. 7.19.4, this returns -1 if the size isn't known.
  139. .IP CURLINFO_CONTENT_TYPE
  140. Pass a pointer to a char pointer to receive the content-type of the downloaded
  141. object. This is the value read from the Content-Type: field. If you get NULL,
  142. it means that the server didn't send a valid Content-Type header or that the
  143. protocol used doesn't support this.
  144. .IP CURLINFO_PRIVATE
  145. Pass a pointer to a char pointer to receive the pointer to the private data
  146. associated with the curl handle (set with the CURLOPT_PRIVATE option to
  147. \fIcurl_easy_setopt(3)\fP). Please note that for internal reasons, the
  148. value is returned as a char pointer, although effectively being a 'void *'.
  149. (Added in 7.10.3)
  150. .IP CURLINFO_HTTPAUTH_AVAIL
  151. Pass a pointer to a long to receive a bitmask indicating the authentication
  152. method(s) available. The meaning of the bits is explained in the
  153. CURLOPT_HTTPAUTH option for \fIcurl_easy_setopt(3)\fP. (Added in 7.10.8)
  154. .IP CURLINFO_PROXYAUTH_AVAIL
  155. Pass a pointer to a long to receive a bitmask indicating the authentication
  156. method(s) available for your proxy authentication. (Added in 7.10.8)
  157. .IP CURLINFO_OS_ERRNO
  158. Pass a pointer to a long to receive the errno variable from a connect failure.
  159. Note that the value is only set on failure, it is not reset upon a
  160. successfull operation. (Added in 7.12.2)
  161. .IP CURLINFO_NUM_CONNECTS
  162. Pass a pointer to a long to receive how many new connections libcurl had to
  163. create to achieve the previous transfer (only the successful connects are
  164. counted). Combined with \fICURLINFO_REDIRECT_COUNT\fP you are able to know
  165. how many times libcurl successfully reused existing connection(s) or not. See
  166. the Connection Options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries
  167. to make persistent connections to save time. (Added in 7.12.3)
  168. .IP CURLINFO_PRIMARY_IP
  169. Pass a pointer to a char pointer to receive the pointer to a zero-terminated
  170. string holding the IP address of the most recent connection done with this
  171. \fBcurl\fP handle. This string may be IPv6 if that's enabled. Note that you
  172. get a pointer to a memory area that will be re-used at next request so you
  173. need to copy the string if you want to keep the information. (Added in 7.19.0)
  174. .IP CURLINFO_COOKIELIST
  175. Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all
  176. cookies cURL knows (expired ones, too). Don't forget to
  177. \fIcurl_slist_free_all(3)\fP the list after it has been used. If there are no
  178. cookies (cookies for the handle have not been enabled or simply none have been
  179. received) 'struct curl_slist *' will be set to point to NULL. (Added in
  180. 7.14.1)
  181. .IP CURLINFO_LASTSOCKET
  182. Pass a pointer to a long to receive the last socket used by this curl
  183. session. If the socket is no longer valid, -1 is returned. When you finish
  184. working with the socket, you must call curl_easy_cleanup() as usual and let
  185. libcurl close the socket and cleanup other resources associated with the
  186. handle. This is typically used in combination with \fICURLOPT_CONNECT_ONLY\fP.
  187. (Added in 7.15.2)
  188. .IP CURLINFO_FTP_ENTRY_PATH
  189. Pass a pointer to a char pointer to receive a pointer to a string holding the
  190. path of the entry path. That is the initial path libcurl ended up in when
  191. logging on to the remote FTP server. This stores a NULL as pointer if
  192. something is wrong. (Added in 7.15.4)
  193. .IP CURLINFO_CERTINFO
  194. Pass a pointer to a 'struct curl_certinfo *' and you'll get it set to point to
  195. struct that holds a number of linked lists with info about the certificate
  196. chain, assuming you had CURLOPT_CERTINFO enabled when the previous request was
  197. done. The struct reports how many certs it found and then you can extract info
  198. for each of those certs by following the linked lists. The info chain is
  199. provided in a series of data in the format "name:content" where the content is
  200. for the specific named data. See also the certinfo.c example. NOTE: this
  201. option is only available in libcurl built with OpenSSL support. (Added in
  202. 7.19.1)
  203. .IP CURLINFO_CONDITION_UNMET
  204. Pass a pointer to a long to receive the number 1 if the condition provided in
  205. the previous request didn't match (see \fICURLOPT_TIMECONDITION\fP). Alas, if
  206. this returns a 1 you know that the reason you didn't get data in return is
  207. because it didn't fulfill the condition. The long ths argument points to will
  208. get a zero stored if the condition instead was met. (Added in 7.19.4)
  209. .IP CURLINFO_RTSP_SESSION_ID
  210. Pass a pointer to a char pointer to receive a pointer to a string holding the
  211. most recent RTSP Session ID.
  212. Applications wishing to resume an RTSP session on another connection should
  213. retreive this info before closing the active connection.
  214. .IP CURLINFO_RTSP_CLIENT_CSEQ
  215. Pass a pointer to a long to receive the next CSeq that will be used by the
  216. application.
  217. .IP CURLINFO_RTSP_SERVER_CSEQ
  218. Pass a pointer to a long to receive the next server CSeq that will be expected
  219. by the application.
  220. \fI(NOTE: listening for server initiated requests is currently
  221. unimplemented).\fP
  222. Applications wishing to resume an RTSP session on another connection should
  223. retreive this info before closing the active connection.
  224. .IP CURLINFO_RTSP_CSEQ_RECV
  225. Pass a pointer to a long to receive the most recently received CSeq from the
  226. server. If your application encounters a \fICURLE_RTSP_CSEQ_ERROR\fP then you
  227. may wish to troubleshoot and/or fix the CSeq mismatch by peeking at this value.
  228. .SH TIMES
  229. .nf
  230. An overview of the six time values available from curl_easy_getinfo()
  231. curl_easy_perform()
  232. |
  233. |--NAMELOOKUP
  234. |--|--CONNECT
  235. |--|--|--APPCONNECT
  236. |--|--|--|--PRETRANSFER
  237. |--|--|--|--|--STARTTRANSFER
  238. |--|--|--|--|--|--TOTAL
  239. |--|--|--|--|--|--REDIRECT
  240. .fi
  241. .IP NAMELOOKUP
  242. \fICURLINFO_NAMELOOKUP_TIME\fP. The time it took from the start until the name
  243. resolving was completed.
  244. .IP CONNECT
  245. \fICURLINFO_CONNECT_TIME\fP. The time it took from the start until the connect
  246. to the remote host (or proxy) was completed.
  247. .IP APPCONNECT
  248. \fICURLINFO_APPCONNECT_TIME\fP. The time it took from the start until the SSL
  249. connect/handshake with the remote host was completed. (Added in in 7.19.0)
  250. .IP PRETRANSFER
  251. \fICURLINFO_PRETRANSFER_TIME\fP. The time it took from the start until the
  252. file transfer is just about to begin. This includes all pre-transfer commands
  253. and negotiations that are specific to the particular protocol(s) involved.
  254. .IP STARTTRANSFER
  255. \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the
  256. first byte is just about to be transferred.
  257. .IP TOTAL
  258. \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request.
  259. .IP REDIRECT
  260. \fICURLINFO_REDIRECT_TIME\fP. The time it took for all redirection steps
  261. include name lookup, connect, pretransfer and transfer before final
  262. transaction was started. So, this is zero if no redirection took place.
  263. .SH RETURN VALUE
  264. If the operation was successful, CURLE_OK is returned. Otherwise an
  265. appropriate error code will be returned.
  266. .SH "SEE ALSO"
  267. .BR curl_easy_setopt "(3)"