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
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms