- Added CURLINFO_PRIMARY_IP as a new information retrievable with
[platform/upstream/curl.git] / docs / libcurl / curl_easy_getinfo.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2008, 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 "21 Mar 2006" "libcurl 7.15.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
30 .B "CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );"
31
32 .SH DESCRIPTION
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
39 data.
40
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
52 this.
53 .IP CURLINFO_HTTP_CONNECTCODE
54 Pass a pointer to a long to receive the last received proxy response code to a
55 CONNECT request.
56 .IP CURLINFO_FILETIME
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
64 in 7.5)
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_PRETRANSFER_TIME
75 Pass a pointer to a double to receive the time, in seconds, it took from the
76 start until the file transfer is just about to begin. This includes all
77 pre-transfer commands and negotiations that are specific to the particular
78 protocol(s) involved.
79 .IP CURLINFO_STARTTRANSFER_TIME
80 Pass a pointer to a double to receive the time, in seconds, it took from the
81 start until the first byte is just about to be transferred. This includes
82 CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate
83 the result.
84 .IP CURLINFO_REDIRECT_TIME
85 Pass a pointer to a double to receive the total time, in seconds, it took for
86 all redirection steps include name lookup, connect, pretransfer and transfer
87 before final transaction was started. CURLINFO_REDIRECT_TIME contains the
88 complete execution time for multiple redirections.  (Added in 7.9.7)
89 .IP CURLINFO_REDIRECT_COUNT
90 Pass a pointer to a long to receive the total number of redirections that were
91 actually followed.  (Added in 7.9.7)
92 .IP CURLINFO_REDIRECT_URL
93 Pass a pointer to a char pointer to receive the URL a redirect \fIwould\fP
94 take you to if you would enable CURLOPT_FOLLOWLOCATION. This can come very
95 handy if you think using the built-in libcurl redirect logic isn't good enough
96 for you but you would still prefer to avoid implementing all the magic of
97 figuring out the new URL. (Added in 7.18.2)
98 .IP CURLINFO_SIZE_UPLOAD
99 Pass a pointer to a double to receive the total amount of bytes that were
100 uploaded.
101 .IP CURLINFO_SIZE_DOWNLOAD
102 Pass a pointer to a double to receive the total amount of bytes that were
103 downloaded. The amount is only for the latest transfer and will be reset again
104 for each new transfer.
105 .IP CURLINFO_SPEED_DOWNLOAD
106 Pass a pointer to a double to receive the average download speed that curl
107 measured for the complete download. Measured in bytes/second.
108 .IP CURLINFO_SPEED_UPLOAD
109 Pass a pointer to a double to receive the average upload speed that curl
110 measured for the complete upload. Measured in bytes/second.
111 .IP CURLINFO_HEADER_SIZE
112 Pass a pointer to a long to receive the total size of all the headers
113 received. Measured in number of bytes.
114 .IP CURLINFO_REQUEST_SIZE
115 Pass a pointer to a long to receive the total size of the issued
116 requests. This is so far only for HTTP requests. Note that this may be more
117 than one request if FOLLOWLOCATION is true.
118 .IP CURLINFO_SSL_VERIFYRESULT
119 Pass a pointer to a long to receive the result of the certification
120 verification that was requested (using the CURLOPT_SSL_VERIFYPEER option to
121 \fIcurl_easy_setopt(3)\fP).
122 .IP CURLINFO_SSL_ENGINES
123 Pass the address of a 'struct curl_slist *' to receive a linked-list of
124 OpenSSL crypto-engines supported. Note that engines are normally implemented
125 in separate dynamic libraries. Hence not all the returned engines may be
126 available at run-time. \fBNOTE:\fP you must call \fIcurl_slist_free_all(3)\fP
127 on the list pointer once you're done with it, as libcurl will not free the
128 data for you. (Added in 7.12.3)
129 .IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
130 Pass a pointer to a double to receive the content-length of the download. This
131 is the value read from the Content-Length: field.
132 .IP CURLINFO_CONTENT_LENGTH_UPLOAD
133 Pass a pointer to a double to receive the specified size of the upload.
134 .IP CURLINFO_CONTENT_TYPE
135 Pass a pointer to a 'char *' to receive the content-type of the downloaded
136 object. This is the value read from the Content-Type: field. If you get NULL,
137 it means that the server didn't send a valid Content-Type header or that the
138 protocol used doesn't support this.
139 .IP CURLINFO_PRIVATE
140 Pass a pointer to a 'char *' to receive the pointer to the private data
141 associated with the curl handle (set with the CURLOPT_PRIVATE option to
142 \fIcurl_easy_setopt(3)\fP). Please note that for internal reasons, the
143 value is returned as a 'char *', although effectively being a 'void *'.
144 (Added in 7.10.3)
145 .IP CURLINFO_HTTPAUTH_AVAIL
146 Pass a pointer to a long to receive a bitmask indicating the authentication
147 method(s) available. The meaning of the bits is explained in the
148 CURLOPT_HTTPAUTH option for \fIcurl_easy_setopt(3)\fP.  (Added in 7.10.8)
149 .IP CURLINFO_PROXYAUTH_AVAIL
150 Pass a pointer to a long to receive a bitmask indicating the authentication
151 method(s) available for your proxy authentication.  (Added in 7.10.8)
152 .IP CURLINFO_OS_ERRNO
153 Pass a pointer to a long to receive the errno variable from a connect failure.
154 (Added in 7.12.2)
155 .IP CURLINFO_NUM_CONNECTS
156 Pass a pointer to a long to receive how many new connections libcurl had to
157 create to achieve the previous transfer (only the successful connects are
158 counted).  Combined with \fICURLINFO_REDIRECT_COUNT\fP you are able to know
159 how many times libcurl successfully reused existing connection(s) or not.  See
160 the Connection Options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries
161 to make persistent connections to save time.  (Added in 7.12.3)
162 .IP CURLINFO_PRIMARY_IP
163 Pass a pointer to a char pointer to receive the pointer to a zero-terminated
164 string holding the IP address of the most recent connection done with this
165 \fBcurl\fP handle. This string may be IPv6 if that's enabled. Note that you
166 get a pointer to a memory area that will be re-used at next request so you
167 need to copy the string if you want to keep the information. (Added in 7.18.3)
168 .IP CURLINFO_COOKIELIST
169 Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all
170 cookies cURL knows (expired ones, too). Don't forget to
171 \fIcurl_slist_free_all(3)\fP the list after it has been used.  If there are no
172 cookies (cookies for the handle have not been enabled or simply none have been
173 received) 'struct curl_slist *' will be set to point to NULL. (Added in
174 7.14.1)
175 .IP CURLINFO_LASTSOCKET
176 Pass a pointer to a long to receive the last socket used by this curl
177 session. If the socket is no longer valid, -1 is returned. When you finish
178 working with the socket, you must call curl_easy_cleanup() as usual and let
179 libcurl close the socket and cleanup other resources associated with the
180 handle. This is typically used in combination with \fICURLOPT_CONNECT_ONLY\fP.
181 (Added in 7.15.2)
182 .IP CURLINFO_FTP_ENTRY_PATH
183 Pass a pointer to a 'char *' to receive a pointer to a string holding the path
184 of the entry path. That is the initial path libcurl ended up in when logging
185 on to the remote FTP server. This stores a NULL as pointer if something is
186 wrong. (Added in 7.15.4)
187 .SH TIMES
188 .NF
189 An overview of the six time values available from curl_easy_getinfo()
190
191 curl_easy_perform()
192     |
193     |--NT
194     |--|--CT
195     |--|--|--PT
196     |--|--|--|--ST
197     |--|--|--|--|--TT
198     |--|--|--|--|--RT
199 .FI
200 .IP NT
201 \fICURLINFO_NAMELOOKUP_TIME\fP. The time it took from the start until the name
202 resolving was completed.
203 .IP CT
204 \fICURLINFO_CONNECT_TIME\fP. The time it took from the start until the connect
205 to the remote host (or proxy) was completed.
206 .IP PT
207 \fICURLINFO_PRETRANSFER_TIME\fP. The time it took from the start until the
208 file transfer is just about to begin. This includes all pre-transfer commands
209 and negotiations that are specific to the particular protocol(s) involved.
210 .IP ST
211 \fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the
212 first byte is just about to be transferred.
213 .IP TT
214 \fICURLINFO_TOTAL_TIME\fP. Total time of the previous request.
215 .IP RT
216 \fICURLINFO_REDIRECT_TIME\fP. The time it took for all redirection steps
217 include name lookup, connect, pretransfer and transfer before final
218 transaction was started. So, this is zero if no redirection took place.
219 .SH RETURN VALUE
220 If the operation was successful, CURLE_OK is returned. Otherwise an
221 appropriate error code will be returned.
222 .SH "SEE ALSO"
223 .BR curl_easy_setopt "(3)"