CURLOPT_SERVICE_NAME(3)

✨ CURLOPT_SERVICE_NAME ✨

okay bestie, welcome to the CURLOPT_SERVICE_NAME page β€” it's part of the libcurl Library Functions Manual, and it's literally all about the name of the service you use for auth. let's get into it πŸ’…


🌸 NAME 🌸

CURLOPT_SERVICE_NAME β€” the authentication service name, aka "what do i call myself when i show up to the auth party" πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVICE_NAME, char *name);

πŸ’– DESCRIPTION πŸ’–

so basically, you pass a char pointer as the parameter, and it points at a string holding the name of the service β€” and that name gets used for the DIGEST-MD5, SPNEGO and Kerberos 5 authentication mechanisms. iykyk πŸ”₯

the default service names are "ftp", "HTTP", "imap", "ldap", "pop" and "smtp". what this option does is let you change them. slay, customization πŸ‘‘

the application does not have to keep the string around after setting this option β€” so you can let it go, no strings attached (literally) 🧚

and if you use this option multiple times? the last set string just overrides the previous ones, no drama. set it to NULL to disable its use again. periodt πŸ’€


⭐ DEFAULT ⭐

See above β€” the defaults are literally listed up there in the description, bestie πŸ™ˆ


🌈 PROTOCOLS 🌈

this functionality affects ftp, http, imap, ldap, pop3 and smtp 🫢


πŸ“ 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_SERVICE_NAME, "custom");
    result = curl_easy_perform(curl);
  }
}

look at that little "custom" service name living its main character life ✨


πŸŽ€ AVAILABILITY πŸŽ€

Added in curl 7.43.0 β€” vintage but iconic πŸ’œ


πŸ’… RETURN VALUE πŸ’…

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (that's 0) means everything was OK 😌 β€” non-zero means an error occurred, and you should go see libcurl-errors(3) for the tea 😭


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole vibe check, bestie πŸ’– this page came to you from libcurl, dated 2026-10-12, and yes the page name is also CURLOPT_SERVICE_NAME(3) because we keep it consistent around here πŸ¦‹ mwah, go set some service names ✨

πŸ“¦ where this page comes from