Sortix nightly manual
This manual documents Sortix nightly, a development build that has not been officially released. You can instead view this document in the latest official manual.
CURLOPT_HEADERFUNCTION(3) | Library Functions Manual | CURLOPT_HEADERFUNCTION(3) |
NAME
CURLOPT_HEADERFUNCTION - callback that receives header dataSYNOPSIS
#include <curl/curl.h>
size_t header_callback(char *buffer,
size_t size,
size_t nitems,
void *userdata);
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERFUNCTION,
header_callback);
DESCRIPTION
Pass a pointer to your callback function, which should match the prototype shown above.LIMITATIONS
libcurl does not unfold HTTP "folded headers" (deprecated since RFC 7230). A folded header is a header that continues on a subsequent line and starts with a whitespace. Such folds are passed to the header callback as separate ones, although strictly they are just continuations of the previous lines.DEFAULT
Nothing.PROTOCOLS
This functionality affects ftp, http, imap, pop3 and smtpEXAMPLE
static size_t header_callback(char *buffer, size_t size,
size_t nitems, void *userdata)
{
/* received header is nitems * size long in 'buffer' NOT ZERO TERMINATED */
/* 'userdata' is set with CURLOPT_HEADERDATA */
return nitems * size;
}
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
curl_easy_perform(curl);
}
}
AVAILABILITY
Added in curl 7.7.2RETURN VALUE
Returns CURLE_OKSEE ALSO
CURLOPT_HEADERDATA(3), CURLOPT_WRITEFUNCTION(3), curl_easy_header(3)2024-11-21 | libcurl |