CURLOPT_HEADEROPT.3 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .\" generated by cd2nroff 0.1 from CURLOPT_HEADEROPT.md
  2. .TH CURLOPT_HEADEROPT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_HEADEROPT \- send HTTP headers to both proxy and host or separately
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADEROPT, long bitmask);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long that is a bitmask of options of how to deal with headers. The two
  12. mutually exclusive options are:
  13. \fBCURLHEADER_UNIFIED\fP \- the headers specified in
  14. \fICURLOPT_HTTPHEADER(3)\fP are used in requests both to servers and
  15. proxies. With this option enabled, \fICURLOPT_PROXYHEADER(3)\fP does not have
  16. any effect.
  17. \fBCURLHEADER_SEPARATE\fP \- makes \fICURLOPT_HTTPHEADER(3)\fP headers only get
  18. sent to a server and not to a proxy. Proxy headers must be set with
  19. \fICURLOPT_PROXYHEADER(3)\fP to get used. Note that if a non\-CONNECT request
  20. is sent to a proxy, libcurl sends both server headers and proxy headers. When
  21. doing CONNECT, libcurl sends \fICURLOPT_PROXYHEADER(3)\fP headers only to the
  22. proxy and then \fICURLOPT_HTTPHEADER(3)\fP headers only to the server.
  23. .SH DEFAULT
  24. CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before then)
  25. .SH PROTOCOLS
  26. This functionality affects http only
  27. .SH EXAMPLE
  28. .nf
  29. int main(void)
  30. {
  31. CURL *curl = curl_easy_init();
  32. if(curl) {
  33. CURLcode ret;
  34. struct curl_slist *list;
  35. list = curl_slist_append(NULL, "Shoesize: 10");
  36. list = curl_slist_append(list, "Accept:");
  37. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  38. curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
  39. curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
  40. /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
  41. libcurl to not send the custom headers to the proxy. Keep them
  42. separate! */
  43. curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
  44. ret = curl_easy_perform(curl);
  45. curl_slist_free_all(list);
  46. curl_easy_cleanup(curl);
  47. }
  48. }
  49. .fi
  50. .SH AVAILABILITY
  51. Added in curl 7.37.0
  52. .SH RETURN VALUE
  53. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  54. .SH SEE ALSO
  55. .BR CURLOPT_HTTPHEADER (3),
  56. .BR CURLOPT_PROXYHEADER (3)