GNURLOPT_PRIVATE(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_PRIVATE(3) β€” the curl_easy_setopt options girly ✨

okay so this page lives in the curl_easy_setopt options manual (gnurl edition, mwah) and it's literally about stashing your pointer somewhere safe so you can find it again later. no cap, that's the whole vibe. πŸŽ€


🌸 NAME 🌸

CURLOPT_PRIVATE β€” store a private pointer, bestie 🫢

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

πŸ’– DESCRIPTION πŸ’–

So you pass a void * as the parameter, right? And that pointer points at literally whatever data you want associated with this curl handle. that's it. that's the whole thing. ✨

The pointer can subsequently be retrieved using curl_easy_getinfo(3) with the CURLINFO_PRIVATE option β€” so you can get it back out whenever you need it, iykyk. πŸ¦‹

And like… the important part? libcurl itself never does anything with this data. it's just holding your bag for you. it does not peek, it does not touch, it does not have opinions. πŸ’…

πŸŽ€ DEFAULT πŸŽ€

NULL β€” yeah, empty, nothing in there, starting fresh.

🌈 PROTOCOLS 🌈

All of them. every single one. periodt.

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
struct private secrets;
if(curl) {
  struct private *extracted;
  curl_easy_setopt(curl, CURLOPT_URL, "http://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);
}

like look at her go 😭 storing the pointer, doing the request, then pulling the pointer back out. main character energy fr fr. πŸ‘‘

⭐ AVAILABILITY ⭐

Added in 7.10.3 β€” vintage but iconic.

πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's the whole tea. πŸ«–

πŸ”₯ SEE ALSO πŸ”₯


ngl this one is so easy it's giving "why did I read the manual" β€” but now you know, and knowing is slaying. πŸ’€βœ¨

okay bye bestie, this page is from libcurl 7.37.0, dated 17 Jun 2014 β€” and yes, GNURLOPT_PRIVATE(3) is the header, love her, mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from