| curl_easy_getinfo(3) | Library Functions Manual | curl_easy_getinfo(3) |
curl_easy_getinfo - extract information from a curl handle
#include <curl/curl.h> CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );
Get the info kept in the curl handle. The third argument MUST be pointing to the specific type of the used option which is documented in each man page of the info option. The data is stored accordingly and can be relied upon only if this function returns CURLE_OK. Use this function after a performed transfer if you want to get transfer related data.
You should not free the memory returned by this function unless it is explicitly mentioned below.
The following information can be extracted:
An overview of the time values available from curl_easy_getinfo(3)
curl_easy_perform()
|
|--QUEUE
|--|--NAMELOOKUP
|--|--|--CONNECT
|--|--|--|--APPCONNECT
|--|--|--|--|--PRETRANSFER
|--|--|--|--|--|--POSTTRANSFER
|--|--|--|--|--|--|--STARTTRANSFER
|--|--|--|--|--|--|--|--TOTAL
|--|--|--|--|--|--|--|--REDIRECT
CURLINFO_QUEUE_TIME_T(3), CURLINFO_NAMELOOKUP_TIME_T(3),
CURLINFO_CONNECT_TIME_T(3), CURLINFO_APPCONNECT_TIME_T(3),
CURLINFO_PRETRANSFER_TIME_T(3),
CURLINFO_POSTTRANSFER_TIME_T(3),
CURLINFO_STARTTRANSFER_TIME_T(3), CURLINFO_TOTAL_TIME_T(3),
CURLINFO_REDIRECT_TIME_T(3)
This functionality affects all supported protocols
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
char *ct;
/* ask for the content-type */
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if((CURLE_OK == res) && ct)
printf("We received Content-Type: %s\n", ct);
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
Added in curl 7.4.1
This function returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) there can be an error message stored in the error buffer when non-zero is returned.
| 2025-11-09 | libcurl |