CURLOPT_HAPROXYPROTOCOL(3)

πŸ’… CURLOPT_HAPROXYPROTOCOL πŸ’…

okay so bestie, you're in the Library Functions Manual section of the curl man pages (yes, that's the manual name, we're being ✨official✨ today) and this one is about CURLOPT_HAPROXYPROTOCOL β€” the little option that makes your connection start with a vibe check for HAProxy. let's get into it πŸŽ€


✨ NAME ✨

CURLOPT_HAPROXYPROTOCOL β€” send HAProxy PROXY protocol v1 header 🫢

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPROXYPROTOCOL,
                          long haproxy_protocol);

✨ DESCRIPTION ✨

so here's the tea β˜• β€” you pass a long parameter set to 1, and that tells the library to send an HAProxy PROXY protocol v1 header right at the beginning of the connection. iconic. and the default action? not sending this header. no header, no drama πŸ’…

this option is primarily useful when you're sending test requests to a service that expects this header β€” like, that service is standing there with its hand out waiting for it, so you gotta deliver πŸ“

most applications do not need this option. fr fr, this is a niche little icon and that's okay πŸ‘‘

✨ DEFAULT ✨

0, do not send any HAProxy PROXY protocol header β€” just pure, headerless energy 🌸

✨ PROTOCOLS ✨

this functionality affects all supported protocols. all of them. every single one. we love an inclusive queen 🌈

✨ EXAMPLE ✨

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    curl_easy_setopt(curl, CURLOPT_HAPROXYPROTOCOL, 1L);
    result = curl_easy_perform(curl);
  }
}

look at her go 😭 setting the URL, setting CURLOPT_HAPROXYPROTOCOL to 1L, and performing. main character energy honestly πŸ”₯

✨ AVAILABILITY ✨

added in curl 7.60.0 β€” a classic, a legend, a pioneer ⭐

✨ RETURN VALUE ✨

curl_easy_setopt(3) returns a CURLcode indicating success or error πŸ’–

CURLE_OK (0) means everything was OK β€” slay βœ… and non-zero means an error occurred 😭 if that happens, go see libcurl-errors(3) for the whole breakdown.

✨ SEE ALSO ✨


and that's the whole page bestie, no cap 🧚

mwah πŸ’‹ β€” brought to you by the libcurl girlies, dated 2026-10-12, and this has been CURLOPT_HAPROXYPROTOCOL(3). iykyk πŸ¦‹

πŸ“¦ where this page comes from