1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
21 .\" * $Id: curl_easy_getinfo.3,v 1.1.1.1 2008-09-23 16:32:05 hoffman Exp $
22 .\" **************************************************************************
24 .TH curl_easy_getinfo 3 "21 Mar 2006" "libcurl 7.15.4" "libcurl Manual"
26 curl_easy_getinfo - extract information from a curl handle
28 .B #include <curl/curl.h>
30 .B "CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );"
33 Request internal information from the curl session with this function. The
34 third argument \fBMUST\fP be a pointer to a long, a pointer to a char *, a
35 pointer to a struct curl_slist * or a pointer to a double (as this
36 documentation describes further down). The data pointed-to will be filled in
37 accordingly and can be relied upon only if the function returns CURLE_OK. Use
38 this function AFTER a performed transfer if you want to get transfer- oriented
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_URL
46 Pass a pointer to a 'char *' to receive the last used effective URL.
47 .IP CURLINFO_RESPONSE_CODE
48 Pass a pointer to a long to receive the last received HTTP or FTP code. This
49 option was known as CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. This
50 will be zero if no server response code has been received. Note that a proxy's
51 CONNECT response should be read with \fICURLINFO_HTTP_CONNECTCODE\fP and not
53 .IP CURLINFO_HTTP_CONNECTCODE
54 Pass a pointer to a long to receive the last received proxy response code to a
57 Pass a pointer to a long to receive the remote time of the retrieved document
58 (in number of seconds since 1 jan 1970 in the GMT/UTC time zone). If you get
59 -1, it can be because of many reasons (unknown, the server hides it or the
60 server doesn't support the command that tells document time etc) and the time
61 of the document is unknown. Note that you must tell the server to collect this
62 information before the transfer is made, by using the CURLOPT_FILETIME option
63 to \fIcurl_easy_setopt(3)\fP or you will unconditionally get a -1 back. (Added
65 .IP CURLINFO_TOTAL_TIME
66 Pass a pointer to a double to receive the total time in seconds for the
67 previous transfer, including name resolving, TCP connect etc.
68 .IP CURLINFO_NAMELOOKUP_TIME
69 Pass a pointer to a double to receive the time, in seconds, it took from the
70 start until the name resolving was completed.
71 .IP CURLINFO_CONNECT_TIME
72 Pass a pointer to a double to receive the time, in seconds, it took from the
73 start until the connect to the remote host (or proxy) was completed.
74 .IP CURLINFO_APPCONNECT_TIME
75 Pass a pointer to a double to receive the time, in seconds, it took from the
76 start until the SSL/SSH connect/handshake to the remote host was completed.
77 This time is most often very near to the PRETRANSFER time, except for cases
78 such as HTTP pippelining where the pretransfer time can be delayed due to
79 waits in line for the pipeline and more. (Added in 7.19.0)
80 .IP CURLINFO_PRETRANSFER_TIME
81 Pass a pointer to a double to receive the time, in seconds, it took from the
82 start until the file transfer is just about to begin. This includes all
83 pre-transfer commands and negotiations that are specific to the particular
85 .IP CURLINFO_STARTTRANSFER_TIME
86 Pass a pointer to a double to receive the time, in seconds, it took from the
87 start until the first byte is just about to be transferred. This includes
88 CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate
90 .IP CURLINFO_REDIRECT_TIME
91 Pass a pointer to a double to receive the total time, in seconds, it took for
92 all redirection steps include name lookup, connect, pretransfer and transfer
93 before final transaction was started. CURLINFO_REDIRECT_TIME contains the
94 complete execution time for multiple redirections. (Added in 7.9.7)
95 .IP CURLINFO_REDIRECT_COUNT
96 Pass a pointer to a long to receive the total number of redirections that were
97 actually followed. (Added in 7.9.7)
98 .IP CURLINFO_REDIRECT_URL
99 Pass a pointer to a char pointer to receive the URL a redirect \fIwould\fP
100 take you to if you would enable CURLOPT_FOLLOWLOCATION. This can come very
101 handy if you think using the built-in libcurl redirect logic isn't good enough
102 for you but you would still prefer to avoid implementing all the magic of
103 figuring out the new URL. (Added in 7.18.2)
104 .IP CURLINFO_SIZE_UPLOAD
105 Pass a pointer to a double to receive the total amount of bytes that were
107 .IP CURLINFO_SIZE_DOWNLOAD
108 Pass a pointer to a double to receive the total amount of bytes that were
109 downloaded. The amount is only for the latest transfer and will be reset again
110 for each new transfer.
111 .IP CURLINFO_SPEED_DOWNLOAD
112 Pass a pointer to a double to receive the average download speed that curl
113 measured for the complete download. Measured in bytes/second.
114 .IP CURLINFO_SPEED_UPLOAD
115 Pass a pointer to a double to receive the average upload speed that curl
116 measured for the complete upload. Measured in bytes/second.
117 .IP CURLINFO_HEADER_SIZE
118 Pass a pointer to a long to receive the total size of all the headers
119 received. Measured in number of bytes.
120 .IP CURLINFO_REQUEST_SIZE
121 Pass a pointer to a long to receive the total size of the issued
122 requests. This is so far only for HTTP requests. Note that this may be more
123 than one request if FOLLOWLOCATION is true.
124 .IP CURLINFO_SSL_VERIFYRESULT
125 Pass a pointer to a long to receive the result of the certification
126 verification that was requested (using the CURLOPT_SSL_VERIFYPEER option to
127 \fIcurl_easy_setopt(3)\fP).
128 .IP CURLINFO_SSL_ENGINES
129 Pass the address of a 'struct curl_slist *' to receive a linked-list of
130 OpenSSL crypto-engines supported. Note that engines are normally implemented
131 in separate dynamic libraries. Hence not all the returned engines may be
132 available at run-time. \fBNOTE:\fP you must call \fIcurl_slist_free_all(3)\fP
133 on the list pointer once you're done with it, as libcurl will not free the
134 data for you. (Added in 7.12.3)
135 .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
136 Pass a pointer to a double to receive the content-length of the download. This
137 is the value read from the Content-Length: field.
138 .IP CURLINFO_CONTENT_LENGTH_UPLOAD
139 Pass a pointer to a double to receive the specified size of the upload.
140 .IP CURLINFO_CONTENT_TYPE
141 Pass a pointer to a 'char *' to receive the content-type of the downloaded
142 object. This is the value read from the Content-Type: field. If you get NULL,
143 it means that the server didn't send a valid Content-Type header or that the
144 protocol used doesn't support this.
146 Pass a pointer to a 'char *' to receive the pointer to the private data
147 associated with the curl handle (set with the CURLOPT_PRIVATE option to
148 \fIcurl_easy_setopt(3)\fP). Please note that for internal reasons, the
149 value is returned as a 'char *', although effectively being a 'void *'.
151 .IP CURLINFO_HTTPAUTH_AVAIL
152 Pass a pointer to a long to receive a bitmask indicating the authentication
153 method(s) available. The meaning of the bits is explained in the
154 CURLOPT_HTTPAUTH option for \fIcurl_easy_setopt(3)\fP. (Added in 7.10.8)
155 .IP CURLINFO_PROXYAUTH_AVAIL
156 Pass a pointer to a long to receive a bitmask indicating the authentication
157 method(s) available for your proxy authentication. (Added in 7.10.8)
158 .IP CURLINFO_OS_ERRNO
159 Pass a pointer to a long to receive the errno variable from a connect failure.
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
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.
188 .IP CURLINFO_FTP_ENTRY_PATH
189 Pass a pointer to a 'char *' to receive a pointer to a string holding the path
190 of the entry path. That is the initial path libcurl ended up in when logging
191 on to the remote FTP server. This stores a NULL as pointer if something is
192 wrong. (Added in 7.15.4)
195 An overview of the six time values available from curl_easy_getinfo()
202 |--|--|--|--PRETRANSFER
203 |--|--|--|--|--STARTTRANSFER
204 |--|--|--|--|--|--TOTAL
205 |--|--|--|--|--|--REDIRECT
208 \fICURLINFO_NAMELOOKUP_TIME\fP. The time it took from the start until the name
209 resolving was completed.
211 \fICURLINFO_CONNECT_TIME\fP. The time it took from the start until the connect
212 to the remote host (or proxy) was completed.
214 \fICURLINFO_APPCONNECT_TIME\fP. The time it took from the start until the SSL
215 connect/handshake with the remote host was completed. (Added in in 7.19.0)
217 \fICURLINFO_PRETRANSFER_TIME\fP. The time it took from the start until the
218 file transfer is just about to begin. This includes all pre-transfer commands
219 and negotiations that are specific to the particular protocol(s) involved.
221 \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the
222 first byte is just about to be transferred.
224 \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request.
226 \fICURLINFO_REDIRECT_TIME\fP. The time it took for all redirection steps
227 include name lookup, connect, pretransfer and transfer before final
228 transaction was started. So, this is zero if no redirection took place.
230 If the operation was successful, CURLE_OK is returned. Otherwise an
231 appropriate error code will be returned.
233 .BR curl_easy_setopt "(3)"