1CURLOPT_HEADEROPT(3) curl_easy_setopt options CURLOPT_HEADEROPT(3)
2
3
4
6 CURLOPT_HEADEROPT - set how to send HTTP headers
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADEROPT, long bit‐
12 mask);
13
15 Pass a long that is a bitmask of options of how to deal with headers.
16 The two mutually exclusive options are:
17
18 CURLHEADER_UNIFIED - the headers specified in CURLOPT_HTTPHEADER(3)
19 will be used in requests both to servers and proxies. With this option
20 enabled, CURLOPT_PROXYHEADER(3) will not have any effect.
21
22 CURLHEADER_SEPARATE - makes CURLOPT_HTTPHEADER(3) headers only get sent
23 to a server and not to a proxy. Proxy headers must be set with CUR‐
24 LOPT_PROXYHEADER(3) to get used. Note that if a non-CONNECT request is
25 sent to a proxy, libcurl will send both server headers and proxy head‐
26 ers. When doing CONNECT, libcurl will send CURLOPT_PROXYHEADER(3) head‐
27 ers only to the proxy and then CURLOPT_HTTPHEADER(3) headers only to
28 the server.
29
31 CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before
32 then)
33
35 HTTP
36
38 CURL *curl = curl_easy_init();
39 if(curl) {
40 CURLcode ret;
41 struct curl_slist *list;
42 list = curl_slist_append(NULL, "Shoesize: 10");
43 list = curl_slist_append(list, "Accept:");
44 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
45 curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
46
47 /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
48 libcurl to not send the custom headers to the proxy. Keep them
49 separate! */
50 curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
51 ret = curl_easy_perform(curl);
52 curl_easy_cleanup(curl);
53 }
54
56 Added in 7.37.0
57
59 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
60 if not.
61
63 CURLOPT_HTTPHEADER(3), CURLOPT_PROXYHEADER(3),
64
65
66
67libcurl 7.61.1 April 17, 2018 CURLOPT_HEADEROPT(3)