CURLMOPT_PUSHDATA(3)

πŸ’… CURLMOPT_PUSHDATA(3) β€” bestie edition

okay so this is a libcurl manual page, from the Library Functions Manual β€” and the star of the show is CURLMOPT_PUSHDATA, which is literally just "a pointer to pass to push callback". That's it. That's the whole vibe. Let's get into it 🫢


✨ NAME ✨

CURLMOPT_PUSHDATA β€” pointer to pass to push callback

🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHDATA, void *pointer);

πŸ’– DESCRIPTION πŸ’–

okay so you know how CURLMOPT_PUSHFUNCTION(3) is the callback that fires when a server tries to push stuff at you? Well, this option lets you set a pointer that gets passed as the last argument to that callback. πŸŽ€

and like β€” the important part, bestie β€” libcurl itself does not touch or use this pointer at all. nope. it's not peeking, it's not dereferencing, it's not doing anything with it. it just... hands it over to your callback. that's the entire job. it's giving personal assistant energy, not main character energy πŸ’…

πŸ¦‹ DEFAULT πŸ¦‹

NULL

🧚 PROTOCOLS 🧚

lowkey this one's specific: this functionality affects http only.

πŸ”₯ EXAMPLE πŸ”₯

here's the whole thing, and yes we're keeping it exactly as-is because it's iconic:

#include <string.h>

/* only allow pushes for filenames starting with "push-" */
int push_callback(CURL *parent,
                  CURL *easy,
                  size_t num_headers,
                  struct curl_pushheaders *headers,
                  void *clientp)
{
  char *headp;
  int *transfers = (int *)clientp;
  FILE *out;
  headp = curl_pushheader_byname(headers, ":path");
  if(headp && !strncmp(headp, "/push-", 6)) {
    fprintf(stderr, "The PATH is %s\n", headp);

    /* save the push here */
    out = fopen("pushed-stream", "wb");

    /* write to this file */
    curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);

    (*transfers)++; /* one more */

    return CURL_PUSH_OK;
  }
  return CURL_PUSH_DENY;
}

int main(void)
{
  int counter;
  CURLM *multi = curl_multi_init();
  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
  curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
}

⭐ AVAILABILITY ⭐

added in curl 7.44.0 β€” so she's been around a minute πŸ’œ

πŸ‘‘ RETURN VALUE πŸ‘‘

curl_multi_setopt(3) returns a CURLMcode indicating success or error. that's the whole tea.

CURLM_OK (0) means everything was OK 😌 and non-zero means an error occurred β€” go check libcurl-errors(3) for the deets.

🌈 SEE ALSO 🌈


ok that's the page!! no cap, every flag and fact survived the vibe check 🫢

and a little sign-off for the credits: this one's from the libcurl library manual, dated 2026-10-12, filed under CURLMOPT_PUSHDATA(3) β€” slay, periodt πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from