GNURLOPT_DOH_URL(3)
π GNURLOPT_DOH_URL(3) β the DNS-over-HTTPS URL one π
okay so bestie, this page is GNURLOPT_DOH_URL(3) from the curl_easy_setopt options manual family, and it's literally all about giving your DNS queries a β¨glow-upβ¨ by routing them through a DNS-over-HTTPS server. ngl, it's giving secure, it's giving private, it's giving main character energy for your resolver.
πΈ NAME πΈ
CURLOPT_DOH_URL β provide the DNS-over-HTTPS URL π¦
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_URL, char *URL);
π DESCRIPTION π
so you pass in a pointer to a URL for the DOH server to use for name resolving, and that's the whole vibe. the parameter should be a char * to a null-terminated string, and it must be URL-encoded in literally this exact format: "https://host:port/path". like, it MUST specify a HTTPS URL β no exceptions, no shortcuts, periodt. π₯
here's the tea though: libcurl doesn't validate the syntax or even use this variable until the transfer is issued. so even if you set a crazy value here (and bestie, you could set the most unhinged string imaginable), curl_easy_setopt(3) will still return CURLE_OK. it's not being shady, it's just not checking yet. π
curl sends POST requests to the given DNS-over-HTTPS URL.
now, to find the DOH server itself β which might be specified using a name β libcurl will use the default name lookup function. you can bootstrap that by providing the address for the DOH server with CURLOPT_RESOLVE(3). iykyk, that's the little chicken-and-egg moment and this is how you solve it. π£
disable DOH use again by setting this option to NULL. bye bye, DOH era. π
π DEFAULT π
NULL β there is no default DOH URL. if this option isn't set, libcurl will use the default name resolver. no DOH, no drama, just the classic. π
π PROTOCOLS π
All π«Ά
π EXAMPLE π
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com");
curl_easy_perform(curl);
}
look at that. iconic. CURLOPT_URL for the actual destination, CURLOPT_DOH_URL for the fancy DNS-over-HTTPS server, and then curl_easy_perform(curl) to make it all happen. chef's kiss. π
β AVAILABILITY β
Added in 7.62.0 β she's not ancient, she's not brand new, she's just right. π«
π RETURN VALUE π
Returns CURLE_OK on success, or CURLE_OUT_OF_MEMORY if there was insufficient heap space. like, your memory said "i simply cannot" and honestly? relatable. π
β οΈ also note (and this is lowkey important): curl_easy_setopt(3) won't actually parse the given string, so if you hand it a bad DOH URL, curl will not detect a problem until it tries to resolve a name with it. so the error shows up fashionably late. π
π₯ SEE ALSO π₯
and that's the whole page bestie, go forth and resolve responsibly πβ¨
sign-off tea: this beauty is from libcurl 7.62.0, dated 18 Jun 2018, and the page itself is GNURLOPT_DOH_URL(3). slay. ππ¦
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 2018, 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