GNURLINFO_SCHEME(3)

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

πŸ¦‹ NAME πŸ¦‹

CURLINFO_SCHEME β€” get the URL scheme (sometimes called protocol) used in the connection. This iconic page is GNURLINFO_SCHEME(3) from the curl_easy_getinfo options manual, bestie πŸ’…βœ¨

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char
**scheme);

πŸ’– DESCRIPTION πŸ’–

Okay so, bestie: pass a pointer to a char pointer, and it receives the pointer to a null-terminated string holding the URL scheme used for the most recent connection done with this CURL handle. That’s the whole assignment. Slay. πŸŽ€

The scheme pointer will be NULL or pointing to private memory you MUST NOT free β€” it gets freed when you call curl_easy_cleanup(3) on the corresponding CURL handle. Hands off, no cap. 🫢

🌈 PROTOCOLS 🌈

All. Literally all of them ✨

πŸŽ€ EXAMPLE πŸŽ€

       CURL *curl = curl_easy_init();
       if(curl) {
         CURLcode res;
         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
         res = curl_easy_perform(curl);
         if(res == CURLE_OK) {
           char *scheme = NULL;
           curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
           if(scheme)
             printf("scheme: %s\n", scheme); /* scheme: HTTP */
         }
         curl_easy_cleanup(curl);
       }

⭐ AVAILABILITY ⭐

Added in 7.52.0. That’s the tea πŸ’–

πŸ”₯ RETURN VALUE πŸ”₯

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Simple, gorgeous, periodt πŸ‘‘

🫢 SEE ALSO 🫢


and that’s the vibe check βœ… β€” this page comes from libcurl 7.52.0, dated 23 November 2016. mwah πŸ’‹πŸ¦‹

πŸ“¦ where this page comes from