CURLOPT_PROXYHEADER(3)
π CURLOPT_PROXYHEADER(3) π
okay so this is a page from the Library Functions Manual, and bestie, it's literally the glow-up guide for CURLOPT_PROXYHEADER β the one that sets which HTTP headers get slid to your proxy. let's get into it π«Ά
β¨ NAME β¨
CURLOPT_PROXYHEADER β the set of HTTP headers you pass to your proxy, no cap π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYHEADER,
struct curl_slist *headers);
π¦ DESCRIPTION π¦
so you're gonna pass a pointer to a linked list of HTTP headers, and those bad boys get sent along in your HTTP request when it goes to a proxy. the rules for this list? literally identical to the CURLOPT_HTTPHEADER(3) option's rules. same energy, same rules, periodt. π
the headers you set with this option are only ever used in requests that get sent to a proxy β and specifically when there's also a request being sent to a host. so it's giving proxy-exclusive, main character only. π
now, huge disclaimer: the first line in a request (the one containing the method, usually a GET or POST) is NOT a header and lowkey cannot be replaced using this option. only the lines that follow the request-line are actually headers. if you add that method line into this list of headers, your request will send an invalid header. π« so like... don't. fr fr.
using this option multiple times? the last set list overrides the previous ones, every time. and if you set it to NULL, that disables its use again. simple as that. β¨
β οΈ important bestie: libcurl does not copy the list. you have to keep it around until after the transfer has completed. like, do not let it get freed mid-transfer, that's a whole mess. π
π DEFAULT π
NULL
π§ PROTOCOLS π§
this functionality affects all supported protocols. all of them. every single one. π
β EXAMPLE β
int main(void)
{
CURL *curl = curl_easy_init();
struct curl_slist *list;
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com:80");
list = curl_slist_append(NULL, "Shoesize: 10");
list = curl_slist_append(list, "Accept:");
curl_easy_setopt(curl, CURLOPT_PROXYHEADER, list);
curl_easy_perform(curl);
curl_slist_free_all(list); /* free the list again */
}
}
look at that Shoesize: 10 header, iconic honestly π
π AVAILABILITY π
added in curl 7.37.0 β so it's been around a minute, she's established π
πΈ RETURN VALUE πΈ
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK. anything non-zero means an error occurred β go check libcurl-errors(3) to find out what went wrong. π
π SEE ALSO π
and that's the whole page bestie, you ate that π«Ά this was libcurl, dated 2026-10-12, page CURLOPT_PROXYHEADER(3) β go forth and proxy your headers correctly, ily πβ¨π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms