GNURLOPT_PROXYAUTH(3)
π GNURLOPT_PROXYAUTH(3) β the curl_easy_setopt options girlies π
okay so bestie, you're in the gnurl corner of the curl_easy_setopt options family, and this one is all about telling libcurl which HTTP auth method(s) to use when it's talking to your proxy. no cap, it's a vibe. β¨
πΈ NAME πΈ
CURLOPT_PROXYAUTH β set the HTTP proxy authentication methods to try π«Ά
π¦ SYNOPSIS π¦
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYAUTH, long
bitmask);
π₯ DESCRIPTION π₯
so you pass a long as the parameter, and it's set to a bitmask β yes babe, a bitmask, and it tells libcurl which HTTP authentication method(s) you want it to use for your proxy authentication. π
here's the tea: if more than one bit is set, libcurl will first query the site to see what authentication methods it supports, and then pick the best one you allow it to use. the way it's out here doing a whole vibe check on the proxy before committing? iconic. but ngl, for some methods this will induce an extra network round-trip β so don't act surprised π
to set the actual name and password, you use the CURLOPT_PROXYUSERPWD(3) option. that's where the credentials live, periodt.
and the bitmask itself? you can construct it by or'ing together the bits that are fully listed and described in the CURLOPT_HTTPAUTH(3) man page. go read that one, iykyk. π
π DEFAULT π
CURLAUTH_BASIC
like, that's the one you get if you don't say anything. the default main character. π
π PROTOCOLS π
HTTP
that's it. that's the list. π¦
β EXAMPLE β
CURL *curl = curl_easy_init();
if(curl) {
CURLcode ret;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
/* use this proxy */
curl_easy_setopt(curl, CURLOPT_PROXY, "http://local.example.com:1080");
/* allow whatever auth the proxy speaks */
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
/* set the proxy credentials */
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "james:007");
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
like yes, CURLAUTH_ANY is giving "i trust the proxy to pick, i'm flexible, i'm chill" energy and honestly? we love a low-maintenance queen. π§ and the credentials are literally james:007. iconic spy moment. π
π AVAILABILITY π
Added in 7.10.7 β so she's been on the scene for a minute, she's a veteran. π
π«Ά RETURN VALUE π«Ά
- Returns
CURLE_OKif the option is supported β - Returns
CURLE_UNKNOWN_OPTIONif not π - Or returns
CURLE_NOT_BUILT_INif the bitmask specified no supported authentication methods π
so like, read your return codes babes, don't just ignore them and then be confused later. π
πΈ SEE ALSO πΈ
β οΈ tiny reminder that this is the gnurl page forCURLOPT_PROXYAUTH, and it's an HTTP-proxy thing β don't go pointing it at other protocols and expecting magic, because the PROTOCOLS section fr fr just saysHTTP.
k bye bestie, go authenticate that proxy and slay πβ¨
β from the libcurl 7.37.0 girlies, dated 19 Jun 2014, with love (and a lot of emoji) ππ¦π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms