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

NAME

6       CURLOPT_HEADEROPT  -  send HTTP headers to both proxy and host or sepa‐
7       rately
8

SYNOPSIS

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

DESCRIPTION

16       Pass  a  long that is a bitmask of options of how to deal with headers.
17       The two mutually exclusive options are:
18
19       CURLHEADER_UNIFIED - the  headers  specified  in  CURLOPT_HTTPHEADER(3)
20       will  be used in requests both to servers and proxies. With this option
21       enabled, CURLOPT_PROXYHEADER(3) will not have any effect.
22
23       CURLHEADER_SEPARATE - makes CURLOPT_HTTPHEADER(3) headers only get sent
24       to  a  server  and  not to a proxy. Proxy headers must be set with CUR‐
25       LOPT_PROXYHEADER(3) to get used. Note that if a non-CONNECT request  is
26       sent  to a proxy, libcurl will send both server headers and proxy head‐
27       ers. When doing CONNECT, libcurl will send CURLOPT_PROXYHEADER(3) head‐
28       ers  only  to  the proxy and then CURLOPT_HTTPHEADER(3) headers only to
29       the server.
30

DEFAULT

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

PROTOCOLS

36       HTTP
37

EXAMPLE

39       CURL *curl = curl_easy_init();
40       if(curl) {
41         CURLcode ret;
42         struct curl_slist *list;
43         list = curl_slist_append(NULL, "Shoesize: 10");
44         list = curl_slist_append(list, "Accept:");
45         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
46         curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
47         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
48
49         /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
50            libcurl to not send the custom headers to the proxy. Keep them
51            separate! */
52         curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
53         ret = curl_easy_perform(curl);
54         curl_slist_free_all(list);
55         curl_easy_cleanup(curl);
56       }
57

AVAILABILITY

59       Added in 7.37.0
60

RETURN VALUE

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

SEE ALSO

66       CURLOPT_HTTPHEADER(3), CURLOPT_PROXYHEADER(3),
67
68
69
70libcurl 7.79.1                September 08, 2021          CURLOPT_HEADEROPT(3)
Impressum