GNURLOPT_CURLU(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_CURLU(3) β€” like, the curl_easy_setopt options girlies, but make it URL-handle-core πŸŽ€

okay so bestie, we're in the curl_easy_setopt options family today and this one is genuinely so handy β€” it's the one where you hand curl a whole CURLU * instead of a boring string. let's get into it ✨


🌸 NAME 🌸

CURLOPT_CURLU β€” set the URL using a CURLU *, no cap πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CURLU, void *pointer);

like, that's the whole vibe. you pass the option name, your handle, and a pointer. iconic. πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

okay so here's the tea: you pass in a pointer to the URL you want to work with. that parameter should be a CURLU * β€” literally a URL handle, not a string, not vibes, an actual CURLU *. 🫢

setting CURLOPT_CURLU(3) will explicitly override CURLOPT_URL(3). like, it wins, periodt. so if you set both, this one is the main character. 🌟

CURLOPT_URL(3) or CURLOPT_CURLU(3) must be set before a transfer is started β€” no transfer without one of them, it's giving prerequisite energy fr.

and here's the cute part: libcurl will use this handle and its contents read-only and will not change its contents. so your URL handle stays exactly as you left it, bestie. πŸ’œ an application can very well update the contents of the URL handle after a transfer is done, and if that same handle is then used in a subsequent request, the updated contents will then be used. so like, you can recycle it and curl will absolutely notice the glow-up. ✨


✨ DEFAULT ✨

the default value of this parameter is NULL. so if you don't set it, it's just... nothing there. empty. a void. πŸ•³οΈ


🌈 PROTOCOLS 🌈

All of them. every single one. we love a flexible queen. πŸ‘‘


πŸ”₯ EXAMPLE πŸ”₯

CURL *handle = curl_easy_init();
CURLU *urlp = curl_url();
int res = 0;
if(curl) {

  res = curl_url_set(urlp, CURLUPART_URL, "http://example.com", 0);

  curl_easy_setopt(handle, CURLOPT_CURLU, urlp);

  ret = curl_easy_perform(handle);

  curl_url_cleanup(urlp);
  curl_easy_cleanup(handle);
}

see how it goes? make the handle, make the URL handle, set the URL part, hand it over with CURLOPT_CURLU, perform, then clean up both. tidy. responsible. we stan. 🧚


⭐ AVAILABILITY ⭐

added in 7.63.0. so if you're on anything older, she's not there yet, sorry bestie 😭


πŸ’€ RETURN VALUE πŸ’€

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. like, it'll tell you straight up whether it knows her or not. πŸ™ˆ


πŸ“ SEE ALSO πŸ“


okay that's the whole page, mwah πŸ’‹ β€” this little love letter to CURLU came from libcurl 7.63.0, dated 28 Oct 2018 (yes the footer is old, she's vintage, she's still slaying). now go set your URLs properly bestie πŸ’–πŸŽ€

πŸ“¦ where this page comes from