CURLOPT_HEADER(3)
π CURLOPT_HEADER(3) β the curl library manual, bestie edition π
So like, this is the libcurl manpage for CURLOPT_HEADER and we're gonna get into it β¨
πΈ NAME πΈ
CURLOPT_HEADER β pass headers to the data stream π«Ά
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADER, long onoff);
π¦ DESCRIPTION π¦
Okay so here's the vibe: you pass the long value onoff set to 1 and that's you asking libcurl to include the headers in the write callback (CURLOPT_WRITEFUNCTION(3)). Iconic. This option is actually relevant for protocols that genuinely have headers or other meta-data, like HTTP and FTP π
Now, real talk: when you ask for the headers to get passed to the same callback as the body, it is not possible to accurately separate them again unless you have detailed knowledge about the protocol in use. So like, good luck separating your snack from your meal, iykyk π
Further β and this is the part people sleep on β the CURLOPT_WRITEFUNCTION(3) callback is limited to only ever getting a maximum of CURL_MAX_WRITE_SIZE bytes passed to it (16KB), while a header can be longer than that. Meanwhile CURLOPT_HEADERFUNCTION(3) supports getting called with headers up to CURL_MAX_HTTP_HEADER bytes big (100KB) π₯
So honestly? It is often better to use CURLOPT_HEADERFUNCTION(3) to get the header data separately. Just saying π
Also a little warning bestie: while named confusingly similar, CURLOPT_HTTPHEADER(3) is the one used to set custom HTTP headers. Totally different thing. Don't get it twisted π
π DEFAULT π
0
π§ PROTOCOLS π§
This functionality affects ftp, http, imap, pop3 and smtp π
π EXAMPLE π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_perform(curl);
}
}
β AVAILABILITY β
Added in curl 7.1 π«Ά
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK β slay. Anything non-zero means an error occurred, so go check libcurl-errors(3) π
πΈ SEE ALSO πΈ
okay that's the whole page, mwah π this was the libcurl manual page, dated 2026-10-12, and yeah β the manual name is CURLOPT_HEADER(3), in case you forgot already π go forth and header responsibly bestie πβ¨
π¦ 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