1curl_easy_getinfo(3) libcurl Manual curl_easy_getinfo(3)
2
3
4
6 curl_easy_getinfo - extract information from a curl handle
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
12
13
15 Request internal information from the curl session with this function.
16 The third argument MUST be a pointer to a long, a pointer to a char *,
17 a pointer to a struct curl_slist * or a pointer to a double (as this
18 documentation describes further down). The data pointed-to will be
19 filled in accordingly and can be relied upon only if the function
20 returns CURLE_OK. Use this function AFTER a performed transfer if you
21 want to get transfer- oriented data.
22
23 You should not free the memory returned by this function unless it is
24 explicitly mentioned below.
25
27 The following information can be extracted:
28
29 CURLINFO_EFFECTIVE_URL
30 Pass a pointer to a 'char *' to receive the last used effective
31 URL.
32
33 CURLINFO_RESPONSE_CODE
34 Pass a pointer to a long to receive the last received HTTP or
35 FTP code. This option was known as CURLINFO_HTTP_CODE in libcurl
36 7.10.7 and earlier. This will be zero if no server response code
37 has been received. Note that a proxy's CONNECT response should
38 be read with CURLINFO_HTTP_CONNECTCODE and not this.
39
40 CURLINFO_HTTP_CONNECTCODE
41 Pass a pointer to a long to receive the last received proxy
42 response code to a CONNECT request.
43
44 CURLINFO_FILETIME
45 Pass a pointer to a long to receive the remote time of the
46 retrieved document (in number of seconds since 1 jan 1970 in the
47 GMT/UTC time zone). If you get -1, it can be because of many
48 reasons (unknown, the server hides it or the server doesn't sup‐
49 port the command that tells document time etc) and the time of
50 the document is unknown. Note that you must tell the server to
51 collect this information before the transfer is made, by using
52 the CURLOPT_FILETIME option to curl_easy_setopt(3) or you will
53 unconditionally get a -1 back. (Added in 7.5)
54
55 CURLINFO_TOTAL_TIME
56 Pass a pointer to a double to receive the total time in seconds
57 for the previous transfer, including name resolving, TCP connect
58 etc.
59
60 CURLINFO_NAMELOOKUP_TIME
61 Pass a pointer to a double to receive the time, in seconds, it
62 took from the start until the name resolving was completed.
63
64 CURLINFO_CONNECT_TIME
65 Pass a pointer to a double to receive the time, in seconds, it
66 took from the start until the connect to the remote host (or
67 proxy) was completed.
68
69 CURLINFO_PRETRANSFER_TIME
70 Pass a pointer to a double to receive the time, in seconds, it
71 took from the start until the file transfer is just about to
72 begin. This includes all pre-transfer commands and negotiations
73 that are specific to the particular protocol(s) involved.
74
75 CURLINFO_STARTTRANSFER_TIME
76 Pass a pointer to a double to receive the time, in seconds, it
77 took from the start until the first byte is just about to be
78 transferred. This includes CURLINFO_PRETRANSFER_TIME and also
79 the time the server needs to calculate the result.
80
81 CURLINFO_REDIRECT_TIME
82 Pass a pointer to a double to receive the total time, in sec‐
83 onds, it took for all redirection steps include name lookup,
84 connect, pretransfer and transfer before final transaction was
85 started. CURLINFO_REDIRECT_TIME contains the complete execution
86 time for multiple redirections. (Added in 7.9.7)
87
88 CURLINFO_REDIRECT_COUNT
89 Pass a pointer to a long to receive the total number of redirec‐
90 tions that were actually followed. (Added in 7.9.7)
91
92 CURLINFO_SIZE_UPLOAD
93 Pass a pointer to a double to receive the total amount of bytes
94 that were uploaded.
95
96 CURLINFO_SIZE_DOWNLOAD
97 Pass a pointer to a double to receive the total amount of bytes
98 that were downloaded. The amount is only for the latest transfer
99 and will be reset again for each new transfer.
100
101 CURLINFO_SPEED_DOWNLOAD
102 Pass a pointer to a double to receive the average download speed
103 that curl measured for the complete download. Measured in
104 bytes/second.
105
106 CURLINFO_SPEED_UPLOAD
107 Pass a pointer to a double to receive the average upload speed
108 that curl measured for the complete upload. Measured in
109 bytes/second.
110
111 CURLINFO_HEADER_SIZE
112 Pass a pointer to a long to receive the total size of all the
113 headers received. Measured in number of bytes.
114
115 CURLINFO_REQUEST_SIZE
116 Pass a pointer to a long to receive the total size of the issued
117 requests. This is so far only for HTTP requests. Note that this
118 may be more than one request if FOLLOWLOCATION is true.
119
120 CURLINFO_SSL_VERIFYRESULT
121 Pass a pointer to a long to receive the result of the certifica‐
122 tion verification that was requested (using the CURLOPT_SSL_VER‐
123 IFYPEER option to curl_easy_setopt(3)).
124
125 CURLINFO_SSL_ENGINES
126 Pass the address of a 'struct curl_slist *' to receive a linked-
127 list of OpenSSL crypto-engines supported. Note that engines are
128 normally implemented in separate dynamic libraries. Hence not
129 all the returned engines may be available at run-time. NOTE: you
130 must call curl_slist_free_all(3) on the list pointer once you're
131 done with it, as libcurl will not free the data for you. (Added
132 in 7.12.3)
133
134 CURLINFO_CONTENT_LENGTH_DOWNLOAD
135 Pass a pointer to a double to receive the content-length of the
136 download. This is the value read from the Content-Length: field.
137
138 CURLINFO_CONTENT_LENGTH_UPLOAD
139 Pass a pointer to a double to receive the specified size of the
140 upload.
141
142 CURLINFO_CONTENT_TYPE
143 Pass a pointer to a 'char *' to receive the content-type of the
144 downloaded object. This is the value read from the Content-Type:
145 field. If you get NULL, it means that the server didn't send a
146 valid Content-Type header or that the protocol used doesn't sup‐
147 port this.
148
149 CURLINFO_PRIVATE
150 Pass a pointer to a 'char *' to receive the pointer to the pri‐
151 vate data associated with the curl handle (set with the CUR‐
152 LOPT_PRIVATE option to curl_easy_setopt(3)). (Added in 7.10.3)
153
154 CURLINFO_HTTPAUTH_AVAIL
155 Pass a pointer to a long to receive a bitmask indicating the
156 authentication method(s) available. The meaning of the bits is
157 explained in the CURLOPT_HTTPAUTH option for
158 curl_easy_setopt(3). (Added in 7.10.8)
159
160 CURLINFO_PROXYAUTH_AVAIL
161 Pass a pointer to a long to receive a bitmask indicating the
162 authentication method(s) available for your proxy authentica‐
163 tion. (Added in 7.10.8)
164
165 CURLINFO_OS_ERRNO
166 Pass a pointer to a long to receive the errno variable from a
167 connect failure. (Added in 7.12.2)
168
169 CURLINFO_NUM_CONNECTS
170 Pass a pointer to a long to receive how many new connections
171 libcurl had to create to achieve the previous transfer (only the
172 successful connects are counted). Combined with CURLINFO_REDI‐
173 RECT_COUNT you are able to know how many times libcurl success‐
174 fully reused existing connection(s) or not. See the Connection
175 Options of curl_easy_setopt(3) to see how libcurl tries to make
176 persistent connections to save time. (Added in 7.12.3)
177
178 CURLINFO_COOKIELIST
179 Pass a pointer to a 'struct curl_slist *' to receive a linked-
180 list of all cookies cURL knows (expired ones, too). Don't forget
181 to curl_slist_free_all(3) the list after it has been used. If
182 there are no cookies (cookies for the handle have not been
183 enabled or simply none have been received) 'struct curl_slist *'
184 will be set to point to NULL. (Added in 7.14.1)
185
186 CURLINFO_LASTSOCKET
187 Pass a pointer to a long to receive the last socket used by this
188 curl session. If the socket is no longer valid, -1 is returned.
189 When you finish working with the socket, you must call
190 curl_easy_cleanup() as usual and let libcurl close the socket
191 and cleanup other resources associated with the handle. This is
192 typically used in combination with CURLOPT_CONNECT_ONLY. (Added
193 in 7.15.2)
194
195 CURLINFO_FTP_ENTRY_PATH
196 Pass a pointer to a 'char *' to receive a pointer to a string
197 holding the path of the entry path. That is the initial path
198 libcurl ended up in when logging on to the remote FTP server.
199 This stores a NULL as pointer if something is wrong. (Added in
200 7.15.4)
201
203 An overview of the six time values available from curl_easy_getinfo()
204
205 curl_easy_perform()
206 |
207 |--NT
208 |--|--CT
209 |--|--|--PT
210 |--|--|--|--ST
211 |--|--|--|--|--TT
212 |--|--|--|--|--RT
213
214 NT CURLINFO_NAMELOOKUP_TIME. The time it took from the start until
215 the name resolving was completed.
216
217 CT CURLINFO_CONNECT_TIME. The time it took from the start until the
218 connect to the remote host (or proxy) was completed.
219
220 PT CURLINFO_PRETRANSFER_TIME. The time it took from the start until
221 the file transfer is just about to begin. This includes all pre-
222 transfer commands and negotiations that are specific to the par‐
223 ticular protocol(s) involved.
224
225 ST CURLINFO_STARTTRANSFER_TIME. The time it took from the start
226 until the first byte is just about to be transferred.
227
228 TT CURLINFO_TOTAL_TIME. Total time of the previous request.
229
230 RT CURLINFO_REDIRECT_TIME. The time it took for all redirection
231 steps include name lookup, connect, pretransfer and transfer
232 before final transaction was started. So, this is zero if no re‐
233 direction took place.
234
236 If the operation was successful, CURLE_OK is returned. Otherwise an
237 appropriate error code will be returned.
238
240 curl_easy_setopt(3)
241
242
243
244libcurl 7.15.4 21 Mar 2006 curl_easy_getinfo(3)