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