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