curl_url(3)

✨ curl_url(3) ✨

okay so bestie, welcome to the Library Functions Manual β€” this is the page for curl_url, and honestly it's the main character of the whole URL API squad πŸŽ€

🌸 NAME 🌸

curl_url β€” create a URL handle πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLU *curl_url();

πŸ’– DESCRIPTION πŸ’–

So this function allocates a URL object and hands you back a CURLU handle for it β€” and that handle is literally the input to every other URL API function. She's the entry point, the door, the vibe check at the front of the club 🫢

It's a handle to a URL object that holds β€” or can hold β€” URL components for a single URL. When the object first gets created, there's obviously no components stored in there yet (baby's empty, she's fresh ✨). You set them in the object afterwards with the curl_url_set(3) function.

ok real talk though: the object must be destroyed with a call to curl_url_cleanup(3) when you don't need it anymore. like, don't just abandon her, that's not the move 😭

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols β€” no cap, all of them πŸ‘‘

πŸ“ EXAMPLE πŸ“

int main(void)
{
  CURLUcode rc;
  CURLU *url = curl_url();
  rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
  if(!rc) {
    char *scheme;
    rc = curl_url_get(url, CURLUPART_SCHEME, &scheme, 0);
    if(!rc) {
      printf("the scheme is %s\n", scheme);
      curl_free(scheme);
    }
    curl_url_cleanup(url);
  }
}

⭐ AVAILABILITY ⭐

Added in curl 7.62.0 β€” she's been around a minute πŸ’œ

πŸ”₯ RETURN VALUE πŸ”₯

Returns a CURLU * if it goes well, or NULL if you're out of memory πŸ’€

🧚 SEE ALSO 🧚


laters bestie 🫢 this page is from libcurl, dated 2026-10-12, and it's the curl_url(3) page β€” go build something iconic with it βœ¨πŸ‘‘

πŸ“¦ where this page comes from