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