GNURLOPT_HEADER(3)
π GNURLOPT_HEADER(3) π
okay so bestie, welcome to the curl_easy_setopt options corner of the manual β this one's all about CURLOPT_HEADER, and ngl it's a classic case of "the name does not mean what you think" π«Ά
β¨ NAME β¨
CURLOPT_HEADER β pass headers to the data stream
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADER, long onoff);
β¨ DESCRIPTION β¨
okay so here's the vibe πΈ β you pass a long value called onoff, and if you set it to 1, you're literally asking libcurl to include the headers in the write callback (CURLOPT_WRITEFUNCTION(3)). icon behavior. this option is only relevant for protocols that actually have headers or other meta-data, like HTTP and FTP π
but likeβ¦ here's the thing. when you ask for the headers to go to the same callback as the body, it is not possible to accurately separate them again without detailed knowledge about the protocol in use. π so like, you can do it, but you're kind of on your own after that.
further (and this part matters, fr fr): the CURLOPT_WRITEFUNCTION(3) callback is limited to only ever get a maximum of CURL_MAX_WRITE_SIZE bytes passed to it (16KB), while a header can be longer. meanwhile CURLOPT_HEADERFUNCTION(3) supports getting called with headers up to CURL_MAX_HTTP_HEADER bytes big (100KB). so like, different ceilings entirely π
so the tea is: it is often better to use CURLOPT_HEADERFUNCTION(3) to get the header data separately. slay.
β οΈ and while it's named confusingly similar β CURLOPT_HTTPHEADER(3) is used to set custom HTTP headers! not this! don't get it twisted bestie π
β¨ DEFAULT β¨
0
β¨ PROTOCOLS β¨
Most π
β¨ EXAMPLE β¨
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_perform(curl);
}
β¨ RETURN VALUE β¨
Returns CURLE_OK. that's it, that's the whole vibe β¨
π¦ SEE ALSO π¦
π and that's the page! this little beauty came to you from libcurl 7.37.0, dated 16 Jun 2014 β yes she's an elder icon and she still ate π bye bestie, go read the HEADERFUNCTION one next, iykyk π§
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2018, 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