GNURLOPT_HEADEROPT(3)
π NAME π
okay bestie, welcome to GNURLOPT_HEADEROPT(3) β this one is literally about setting how to send HTTP headers. no cap, that's the whole vibe.
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADEROPT, long
bitmask);
π¦ DESCRIPTION π¦
You pass a long that is a bitmask of options for how to deal with headers. The two mutually exclusive options are:
CURLHEADER_UNIFIEDβ the headers specified inCURLOPT_HTTPHEADER(3)will be used in requests both to servers and proxies. With this option enabled,CURLOPT_PROXYHEADER(3)will not have any effect.CURLHEADER_SEPARATEβ makesCURLOPT_HTTPHEADER(3)headers only get sent to a server and not to a proxy. Proxy headers must be set withCURLOPT_PROXYHEADER(3)to get used. Note that if a non-CONNECT request is sent to a proxy, libcurl will send both server headers and proxy headers. When doing CONNECT, libcurl will sendCURLOPT_PROXYHEADER(3)headers only to the proxy and thenCURLOPT_HTTPHEADER(3)headers only to the server.
π DEFAULT π
CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before then)
πΈ PROTOCOLS πΈ
HTTP
π«Ά EXAMPLE π«Ά
CURL *curl = curl_easy_init();
if(curl) {
CURLcode ret;
struct curl_slist *list;
list = curl_slist_append(NULL, "Shoesize: 10");
list = curl_slist_append(list, "Accept:");
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
/* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
libcurl to not send the custom headers to the proxy. Keep them
separate! */
curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
ret = curl_easy_perform(curl);
curl_slist_free_all(list);
curl_easy_cleanup(curl);
}
π AVAILABILITY π
Added in 7.37.0
π RETURN VALUE π
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
π SEE ALSO π
and that's the whole little header saga, bestie π sign-off tea: this page is from libcurl 7.37.0, dated 19 Jun 2014 β iconic, honestly. π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2019, 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