CURLOPT_PRIVATE(3)

πŸ’… CURLOPT_PRIVATE(3) β€” the libcurl manual, bestie edition πŸŽ€

ok so this is a page from the Library Functions Manual and it's literally all about CURLOPT_PRIVATE, which is your little "stash my own pointer here" button. no cap, it's the chillest option in the whole toolkit. ✨


🌸 NAME 🌸

CURLOPT_PRIVATE β€” store a private pointer 🫢


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRIVATE, void *pointer);

πŸ’– DESCRIPTION πŸ’–

Okay so picture this: you pass a void * as the parameter, and that pointer points at whatever data you wanna associate with this curl handle. that's it. that's the whole vibe. πŸ¦‹

Later on you can pull that same pointer back out using curl_easy_getinfo(3) with the CURLINFO_PRIVATE(3) option β€” like checking your bag and getting your own stuff back, iconic behavior honestly.

and here's the important part, bestie: libcurl itself never does anything with this data. not a single thing. it just holds onto it for you like the world's most trustworthy friend. πŸ’œ


πŸŽ€ DEFAULT πŸŽ€

NULL

(as in, nothing stashed. empty bag. clean slate. 😌)


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols. every single one. she's universal. πŸ‘‘


⭐ EXAMPLE ⭐

struct private {
  void *custom;
};

int main(void)
{
  CURL *curl = curl_easy_init();
  struct private secrets;
  if(curl) {
    struct private *extracted;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

    /* store a pointer to our private struct */
    curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets);

    curl_easy_perform(curl);

    /* we can extract the private pointer again too */
    curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted);
  }
}

see how it works?? you set it, curl carries it around for you, then you get it back. it's giving "emotional support pointer." πŸ˜­πŸ’–


πŸ¦‹ AVAILABILITY πŸ¦‹

Added in curl 7.10.3 β€” so yeah, she's been around a minute. vintage but make it fresh. ⭐


πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error.

  • CURLE_OK (0) means everything was OK β€” we love a zero. πŸŽ‰
  • non-zero means an error occurred, so go peek at libcurl-errors(3) for the tea.

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page, bestie!! go forth and stash your pointers responsibly πŸ’…βœ¨

mwah πŸ’‹ β€” this lil rewrite was brought to you by libcurl, dated 2026-10-12, on the CURLOPT_PRIVATE(3) page. slay, bye!! πŸŽ€

πŸ“¦ where this page comes from