Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / docs / libcurl / curl_easy_getinfo.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2014, 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
64 \fICURLOPT_FILETIME(3)\fP option to \fIcurl_easy_setopt(3)\fP or you will
65 unconditionally get a -1 back. (Added 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 pipelining where the pretransfer time can be delayed due to waits
80 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 \fICURLOPT_FOLLOWLOCATION(3)\fP. This can come
103 very handy if you think using the built-in libcurl redirect logic isn't good
104 enough for you but you would still prefer to avoid implementing all the magic
105 of 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. This counts actual payload data, what's also commonly
113 called body. All meta and header data are excluded and will not be counted in
114 this number.
115 .IP CURLINFO_SPEED_DOWNLOAD
116 Pass a pointer to a double to receive the average download speed that curl
117 measured for the complete download. Measured in bytes/second.
118 .IP CURLINFO_SPEED_UPLOAD
119 Pass a pointer to a double to receive the average upload speed that curl
120 measured for the complete upload. Measured in bytes/second.
121 .IP CURLINFO_HEADER_SIZE
122 Pass a pointer to a long to receive the total size of all the headers
123 received. Measured in number of bytes.
124 .IP CURLINFO_REQUEST_SIZE
125 Pass a pointer to a long to receive the total size of the issued
126 requests. This is so far only for HTTP requests. Note that this may be more
127 than one request if FOLLOWLOCATION is true.
128 .IP CURLINFO_SSL_VERIFYRESULT
129 Pass a pointer to a long to receive the result of the certification
130 verification that was requested (using the \fICURLOPT_SSL_VERIFYPEER(3)\fP
131 option to \fIcurl_easy_setopt(3)\fP).
132 .IP CURLINFO_SSL_ENGINES
133 Pass the address of a 'struct curl_slist *' to receive a linked-list of
134 OpenSSL crypto-engines supported. Note that engines are normally implemented
135 in separate dynamic libraries. Hence not all the returned engines may be
136 available at run-time. \fBNOTE:\fP you must call \fIcurl_slist_free_all(3)\fP
137 on the list pointer once you're done with it, as libcurl will not free the
138 data for you. (Added in 7.12.3)
139 .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
140 Pass a pointer to a double to receive the content-length of the download. This
141 is the value read from the Content-Length: field. Since 7.19.4, this returns -1
142 if the size isn't known.
143 .IP CURLINFO_CONTENT_LENGTH_UPLOAD
144 Pass a pointer to a double to receive the specified size of the upload.  Since
145 7.19.4, this returns -1 if the size isn't known.
146 .IP CURLINFO_CONTENT_TYPE
147 Pass a pointer to a char pointer to receive the content-type of the downloaded
148 object. This is the value read from the Content-Type: field. If you get NULL,
149 it means that the server didn't send a valid Content-Type header or that the
150 protocol used doesn't support this.
151 .IP CURLINFO_PRIVATE
152 Pass a pointer to a char pointer to receive the pointer to the private data
153 associated with the curl handle (set with the \fICURLOPT_PRIVATE(3)\fP option
154 to \fIcurl_easy_setopt(3)\fP). Please note that for internal reasons, the
155 value is returned as a char pointer, although effectively being a 'void *'.
156 (Added in 7.10.3)
157 .IP CURLINFO_HTTPAUTH_AVAIL
158 Pass a pointer to a long to receive a bitmask indicating the authentication
159 method(s) available. The meaning of the bits is explained in the
160 \fICURLOPT_HTTPAUTH(3)\fP option for \fIcurl_easy_setopt(3)\fP.  (Added in
161 7.10.8)
162 .IP CURLINFO_PROXYAUTH_AVAIL
163 Pass a pointer to a long to receive a bitmask indicating the authentication
164 method(s) available for your proxy authentication.  (Added in 7.10.8)
165 .IP CURLINFO_OS_ERRNO
166 Pass a pointer to a long to receive the errno variable from a connect failure.
167 Note that the value is only set on failure, it is not reset upon a
168 successful operation.  (Added in 7.12.2)
169 .IP CURLINFO_NUM_CONNECTS
170 Pass a pointer to a long to receive how many new connections libcurl had to
171 create to achieve the previous transfer (only the successful connects are
172 counted).  Combined with \fICURLINFO_REDIRECT_COUNT\fP you are able to know
173 how many times libcurl successfully reused existing connection(s) or not.  See
174 the Connection Options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries
175 to make persistent connections to save time.  (Added in 7.12.3)
176 .IP CURLINFO_PRIMARY_IP
177 Pass a pointer to a char pointer to receive the pointer to a zero-terminated
178 string holding the IP address of the most recent connection done with this
179 \fBcurl\fP handle. This string may be IPv6 if that's enabled. Note that you
180 get a pointer to a memory area that will be re-used at next request so you
181 need to copy the string if you want to keep the information. (Added in 7.19.0)
182 .IP CURLINFO_PRIMARY_PORT
183 Pass a pointer to a long to receive the destination port of the most recent
184 connection done with this \fBcurl\fP handle. (Added in 7.21.0)
185 .IP CURLINFO_LOCAL_IP
186 Pass a pointer to a char pointer to receive the pointer to a zero-terminated
187 string holding the local (source) IP address of the most recent connection done
188 with this \fBcurl\fP handle. This string may be IPv6 if that's enabled. The
189 same restrictions apply as to \fICURLINFO_PRIMARY_IP\fP. (Added in 7.21.0)
190 .IP CURLINFO_LOCAL_PORT
191 Pass a pointer to a long to receive the local (source) port of the most recent
192 connection done with this \fBcurl\fP handle. (Added in 7.21.0)
193 .IP CURLINFO_COOKIELIST
194 Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all
195 cookies cURL knows (expired ones, too). Don't forget to
196 \fIcurl_slist_free_all(3)\fP the list after it has been used.  If there are no
197 cookies (cookies for the handle have not been enabled or simply none have been
198 received) 'struct curl_slist *' will be set to point to NULL. (Added in
199 7.14.1)
200 .IP CURLINFO_LASTSOCKET
201 Pass a pointer to a long to receive the last socket used by this curl
202 session. If the socket is no longer valid, -1 is returned. When you finish
203 working with the socket, you must call curl_easy_cleanup() as usual and let
204 libcurl close the socket and cleanup other resources associated with the
205 handle. This is typically used in combination with
206 \fICURLOPT_CONNECT_ONLY(3)\fP.  (Added in 7.15.2)
207
208 NOTE: this API is not really working on win64, since the SOCKET type on win64
209 is 64 bit large while its 'long' is only 32 bits.
210 .IP CURLINFO_FTP_ENTRY_PATH
211 Pass a pointer to a char pointer to receive a pointer to a string holding the
212 path of the entry path. That is the initial path libcurl ended up in when
213 logging on to the remote FTP server. This stores a NULL as pointer if
214 something is wrong. (Added in 7.15.4)
215
216 Also works for SFTP since 7.21.4
217 .IP CURLINFO_CERTINFO
218 Pass a pointer to a 'struct curl_certinfo *' and you'll get it set to point to
219 struct that holds a number of linked lists with info about the certificate
220 chain, assuming you had \fICURLOPT_CERTINFO(3)\fP enabled when the previous
221 request was done. The struct reports how many certs it found and then you can
222 extract info for each of those certs by following the linked lists. The info
223 chain is provided in a series of data in the format "name:content" where the
224 content is for the specific named data. See also the certinfo.c example. NOTE:
225 this option is only available in libcurl built with OpenSSL, NSS or GSKit
226 support. (Added in 7.19.1)
227 .IP CURLINFO_TLS_SESSION
228 Pass a pointer to a 'struct curl_tlssessioninfo *'.  The pointer will be
229 initialized to refer to a 'struct curl_tlssessioninfo *' that will contain an
230 enum indicating the SSL library used for the handshake and the respective
231 internal TLS session structure of this underlying SSL library.
232
233 This may then be used to extract certificate information in a format
234 convenient for further processing, such as manual validation. NOTE: this
235 option may not be available for all SSL backends; unsupported SSL backends
236 will return 'CURLSSLBACKEND_NONE' to indicate that they are not supported;
237 this does not mean that no SSL backend was used. (Added in 7.34.0)
238
239 .IP CURLINFO_CONDITION_UNMET
240 Pass a pointer to a long to receive the number 1 if the condition provided in
241 the previous request didn't match (see \fICURLOPT_TIMECONDITION(3)\fP). Alas,
242 if this returns a 1 you know that the reason you didn't get data in return is
243 because it didn't fulfill the condition. The long ths argument points to will
244 get a zero stored if the condition instead was met. (Added in 7.19.4)
245 .IP CURLINFO_RTSP_SESSION_ID
246 Pass a pointer to a char pointer to receive a pointer to a string holding the
247 most recent RTSP Session ID.
248
249 Applications wishing to resume an RTSP session on another connection should
250 retrieve this info before closing the active connection.
251 .IP CURLINFO_RTSP_CLIENT_CSEQ
252 Pass a pointer to a long to receive the next CSeq that will be used by the
253 application.
254 .IP CURLINFO_RTSP_SERVER_CSEQ
255 Pass a pointer to a long to receive the next server CSeq that will be expected
256 by the application.
257
258 \fI(NOTE: listening for server initiated requests is currently
259 unimplemented).\fP
260
261 Applications wishing to resume an RTSP session on another connection should
262 retrieve this info before closing the active connection.
263 .IP CURLINFO_RTSP_CSEQ_RECV
264 Pass a pointer to a long to receive the most recently received CSeq from the
265 server. If your application encounters a \fICURLE_RTSP_CSEQ_ERROR\fP then you
266 may wish to troubleshoot and/or fix the CSeq mismatch by peeking at this value.
267 .SH TIMES
268 .nf
269 An overview of the six time values available from curl_easy_getinfo()
270
271 curl_easy_perform()
272     |
273     |--NAMELOOKUP
274     |--|--CONNECT
275     |--|--|--APPCONNECT
276     |--|--|--|--PRETRANSFER
277     |--|--|--|--|--STARTTRANSFER
278     |--|--|--|--|--|--TOTAL
279     |--|--|--|--|--|--REDIRECT
280 .fi
281 .IP NAMELOOKUP
282 \fICURLINFO_NAMELOOKUP_TIME\fP. The time it took from the start until the name
283 resolving was completed.
284 .IP CONNECT
285 \fICURLINFO_CONNECT_TIME\fP. The time it took from the start until the connect
286 to the remote host (or proxy) was completed.
287 .IP APPCONNECT
288 \fICURLINFO_APPCONNECT_TIME\fP. The time it took from the start until the SSL
289 connect/handshake with the remote host was completed. (Added in in 7.19.0)
290 .IP PRETRANSFER
291 \fICURLINFO_PRETRANSFER_TIME\fP. The time it took from the start until the
292 file transfer is just about to begin. This includes all pre-transfer commands
293 and negotiations that are specific to the particular protocol(s) involved.
294 .IP STARTTRANSFER
295 \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the
296 first byte is received by libcurl.
297 .IP TOTAL
298 \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request.
299 .IP REDIRECT
300 \fICURLINFO_REDIRECT_TIME\fP. The time it took for all redirection steps
301 include name lookup, connect, pretransfer and transfer before final
302 transaction was started. So, this is zero if no redirection took place.
303 .SH RETURN VALUE
304 If the operation was successful, CURLE_OK is returned. Otherwise an
305 appropriate error code will be returned.
306 .SH "SEE ALSO"
307 .BR curl_easy_setopt "(3)"