CURLINFO_PROTOCOL(3)

πŸ’… CURLINFO_PROTOCOL(3)

ok so real talk bestie, this one's a page out of the Library Functions Manual and it's about peeking at which URL scheme (a.k.a. protocol) your last transfer used. it's cute, it's short, it's also kinda deprecated 😭 β€” more on that in a sec.


✨ NAME ✨

CURLINFO_PROTOCOL β€” the URL scheme used in a transfer πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROTOCOL, long *p);

🌸 DESCRIPTION 🌸

okay so first things first, bestie: this option is deprecated, like genuinely. we strongly recommend you use CURLINFO_SCHEME(3) instead, because this one literally can't return all possible schemes β€” it's giving limited edition in a bad way πŸ™ˆ. also fyi, the scheme is sometimes also called the "protocol", which is why the name is Like That πŸ’€.

the vibe: you pass a pointer to a long, and it receives the scheme used in the last transfer. the returned value gets set to one of these:

CURLPROTO_DICT, CURLPROTO_FILE, CURLPROTO_FTP, CURLPROTO_FTPS,
CURLPROTO_GOPHER, CURLPROTO_HTTP, CURLPROTO_HTTPS, CURLPROTO_IMAP,
CURLPROTO_IMAPS, CURLPROTO_LDAP, CURLPROTO_LDAPS, CURLPROTO_POP3,
CURLPROTO_POP3S, CURLPROTO_RTMP, CURLPROTO_RTMPE, CURLPROTO_RTMPS,
CURLPROTO_RTMPT, CURLPROTO_RTMPTE, CURLPROTO_RTMPTS, CURLPROTO_RTSP,
CURLPROTO_SCP, CURLPROTO_SFTP, CURLPROTO_SMB, CURLPROTO_SMBS, CURLPROTO_SMTP,
CURLPROTO_SMTPS, CURLPROTO_TELNET, CURLPROTO_TFTP, CURLPROTO_MQTT

slay, that's the whole list, no cap πŸ”₯


🌈 PROTOCOLS 🌈

this functionality affects all supported protocols β€” every single one, periodt πŸ‘‘


πŸ“ EXAMPLE πŸ“

here's the moment you've been waiting for, a whole little main:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    result = curl_easy_perform(curl);
    if(result == CURLE_OK) {
      long scheme;
      curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &scheme);
    }
    curl_easy_cleanup(curl);
  }
}

look at her go 😌✨


πŸ’€ DEPRECATED πŸ’€

deprecated since 7.85.0. yeah. she's retired. still iconic, but retired 🫢


🧚 AVAILABILITY 🧚

added in curl 7.52.0 β€” so if you're on something ancient, this is not gonna be your moment, ngl.


⭐ RETURN VALUE ⭐

curl_easy_getinfo(3) returns a CURLcode that tells you success or error.

CURLE_OK (0) means everything was OK πŸ’–, and non-zero means an error occurred β€” go check libcurl-errors(3) for the details, iykyk.


πŸ‘‘ SEE ALSO πŸ‘‘


ngl bestie, if you take one thing from this page: it's CURLINFO_SCHEME(3) o'clock. this one's deprecated, remember? πŸ’…

ok bye love you, this page came from libcurl and it's dated 2026-10-12 β€” go forth and read your schemes responsibly πŸŒΈπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from