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