1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_HEADEROPT 5Section: 3 6Source: libcurl 7Protocol: 8 - HTTP 9See-also: 10 - CURLOPT_HTTPHEADER (3) 11 - CURLOPT_PROXYHEADER (3) 12--- 13 14# NAME 15 16CURLOPT_HEADEROPT - send HTTP headers to both proxy and host or separately 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADEROPT, long bitmask); 24~~~ 25 26# DESCRIPTION 27 28Pass a long that is a bitmask of options of how to deal with headers. The two 29mutually exclusive options are: 30 31**CURLHEADER_UNIFIED** - the headers specified in 32CURLOPT_HTTPHEADER(3) are used in requests both to servers and 33proxies. With this option enabled, CURLOPT_PROXYHEADER(3) does not have 34any effect. 35 36**CURLHEADER_SEPARATE** - makes CURLOPT_HTTPHEADER(3) headers only get 37sent to a server and not to a proxy. Proxy headers must be set with 38CURLOPT_PROXYHEADER(3) to get used. Note that if a non-CONNECT request 39is sent to a proxy, libcurl sends both server headers and proxy headers. When 40doing CONNECT, libcurl sends CURLOPT_PROXYHEADER(3) headers only to the 41proxy and then CURLOPT_HTTPHEADER(3) headers only to the server. 42 43# DEFAULT 44 45CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before then) 46 47# EXAMPLE 48 49~~~c 50int main(void) 51{ 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode ret; 55 struct curl_slist *list; 56 list = curl_slist_append(NULL, "Shoesize: 10"); 57 list = curl_slist_append(list, "Accept:"); 58 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 59 curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); 60 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); 61 62 /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell 63 libcurl to not send the custom headers to the proxy. Keep them 64 separate! */ 65 curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE); 66 ret = curl_easy_perform(curl); 67 curl_slist_free_all(list); 68 curl_easy_cleanup(curl); 69 } 70} 71~~~ 72 73# AVAILABILITY 74 75Added in 7.37.0 76 77# RETURN VALUE 78 79Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 80