1CURLOPT_HEADEROPT(3)       curl_easy_setopt options       CURLOPT_HEADEROPT(3)
2
3
4

NAME

6       CURLOPT_HEADEROPT - set how to send HTTP headers
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode  curl_easy_setopt(CURL  *handle,  CURLOPT_HEADEROPT, long bit‐
12       mask);
13

DESCRIPTION

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

DEFAULT

31       CURLHEADER_SEPARATE  (changed in 7.42.1, used CURLHEADER_UNIFIED before
32       then)
33

PROTOCOLS

35       HTTP
36

EXAMPLE

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         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
47
48         /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
49            libcurl to not send the custom headers to the proxy. Keep them
50            separate! */
51         curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
52         ret = curl_easy_perform(curl);
53         curl_slist_free_all(list);
54         curl_easy_cleanup(curl);
55       }
56

AVAILABILITY

58       Added in 7.37.0
59

RETURN VALUE

61       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
62       if not.
63

SEE ALSO

65       CURLOPT_HTTPHEADER(3), CURLOPT_PROXYHEADER(3),
66
67
68
69libcurl 7.76.1                 November 04, 2020          CURLOPT_HEADEROPT(3)
Impressum