curl_easy_getinfo(3)

πŸ’– curl_easy_getinfo(3) πŸ’–

from the Library Functions Manual β€” yes bestie, we're deep in the man pages now. 🫢

🌸 NAME 🌸

curl_easy_getinfo β€” extract information from a curl handle. Like, it's the info desk for your curl handle, periodt. πŸ’…

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );

πŸ’« DESCRIPTION πŸ’«

Okay so this function gets the info kept in the curl handle. The third argument MUST be pointing to the specific type of the used option β€” and each info option's own man page documents that type. Don't just vibe-check it, bestie, get the type right. 😭

The data is stored accordingly, and you can only rely on it if this function returns CURLE_OK. So like, check the return value, no cap. Use this function after a performed transfer if you want to get transfer related data. Yes, after β€” it's giving "receipts after the fact." πŸ”₯

🚨 Important: You should not free the memory returned by this function unless it is explicitly mentioned below. Like, do not touch it. Leave it alone. Periodt. πŸ’€

πŸŽ€ OPTIONS πŸŽ€

The following information can be extracted β€” okay bestie, here's the menu:

⏰ TIMES ⏰

okay so this part is an overview of the time values available from curl_easy_getinfo(3) β€” and highkey the way they nest together is giving main character energy, no cap. here's the exact timeline tree vibe:

       curl_easy_perform()
           |
           |--QUEUE
           |--|--NAMELOOKUP
           |--|--|--CONNECT
           |--|--|--|--APPCONNECT
           |--|--|--|--|--PRETRANSFER
           |--|--|--|--|--|--POSTTRANSFER
           |--|--|--|--|--|--|--STARTTRANSFER
           |--|--|--|--|--|--|--|--TOTAL
           |--|--|--|--|--|--|--|--REDIRECT

and these are the time constants you can ask for, bestie, in this exact order:

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols ✨

πŸŽ€ EXAMPLE πŸŽ€

bestie, here's the whole C example in all its glory β€” it asks for the content-type and prints it if the result is CURLE_OK, fr fr:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
    result = curl_easy_perform(curl);

    if(CURLE_OK == result) {
      char *ct;
      /* ask for the content-type */
      result = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);

      if((CURLE_OK == result) && ct)
        printf("We received Content-Type: %s\n", ct);
    }

    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

πŸ¦‹ AVAILABILITY πŸ¦‹

Added in curl 7.4.1 β€” periodt. πŸ’…

πŸ’… RETURN VALUE πŸ’…

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. ngl, that's the whole return-value tea 🍡

🌸 SEE ALSO 🌸


this iconic page is from libcurl, dated 2026-10-12, and it's all about curl_easy_getinfo(3) β€” hope you slayed those time values, bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from