GNURLOPT_HEADERDATA(3)
πΈ GNURLOPT_HEADERDATA(3) πΈ
okay so this page is from the curl_easy_setopt options manual, and it's all about GNURLOPT_HEADERDATA(3) β yes bestie, the header-data pointer situation. let's get into it π
β¨ NAME β¨
CURLOPT_HEADERDATA β pointer to pass to header callback π«Ά
π¦ SYNOPSIS π¦
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERDATA, void
*pointer);
π DESCRIPTION π
You pass a pointer in, and that pointer is used to write the header part of the received data to. literally that's its whole job β¨
If you're using CURLOPT_WRITEFUNCTION(3) or CURLOPT_HEADERFUNCTION(3), then that pointer gets passed in to the matching callback. your callback can do its thing with it, iykyk π«
If neither of those options is set, then pointer must be a valid FILE *, and a plain fwrite() will use it to write headers to. no cap, that's the requirement π
π DEFAULT π
NULL
π PROTOCOLS π
All β every single one, slay π
π₯ EXAMPLE π₯
struct my_info {
int shoesize;
char *secret;
};
static size_t header_callback(char *buffer, size_t size,
size_t nitems, void *userdata)
{
struct my_info *i = (struct my_info *)userdata;
/* now this callback can access the my_info struct */
return nitems * size;
}
CURL *curl = curl_easy_init();
if(curl) {
struct my_info my = { 10, "the cookies are in the cupboard" };
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
/* pass in custom data to the callback */
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &my);
curl_easy_perform(curl);
}
β AVAILABILITY β
Always β like, always always π
π RETURN VALUE π
Returns CURLE_OK π
π«Ά SEE ALSO π«Ά
mwah π this page is from libcurl 7.37.0, dated 17 Jun 2014 β bye bestie, go pass that pointer with main character energy π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms