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_TIME |--|--NAMELOOKUP |--|--|--CONNECT |--|--|--|--APPCONNECT |--|--|--|--|--PRETRANSFER |--|--|--|--|--|--STARTTRANSFER |--|--|--|--|--|--|--TOTAL |--|--|--|--|--|--|--REDIRECT
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 7.4.1
If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code is returned.
curl_easy_setopt(3)
March 12 2024 | libcurl |