CURLINFO_SCHEME(3)
π CURLINFO_SCHEME(3) π
okay so bestie, this is the CURLINFO_SCHEME page from the Library Functions Manual, and it's literally the glow-up guide for finding out which URL scheme your transfer used β¨. No cap, it's a little libcurl info-getter and it ate.
β¨ NAME β¨
CURLINFO_SCHEME β URL scheme used in transfer π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char **scheme);
π¦ DESCRIPTION π¦
okay so picture this: you 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 transfer done with this CURL handle. iconic. π«Ά
The scheme might also sometimes be referred to as the protocol β iykyk, same vibe, different word.
bestie, listen: the scheme pointer isNULLor points to private memory. You must not free it. π The memory gets freed automatically when you callcurl_easy_cleanup(3)on the corresponding curl handle. So don't be out here doing manual cleanup on borrowed memory, fr fr.
The returned scheme might be upper or lowercase. Do comparisons case insensitively. periodt. π
π PROTOCOLS π
This functionality affects all supported protocols β¨.
π EXAMPLE π
like, here's the whole cute little main character moment:
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) {
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 curl 7.52.0 π.
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error. slay.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3) π.
π¦ SEE ALSO π¦
CURLINFO_EFFECTIVE_URL(3)CURLINFO_PROTOCOL(3)CURLINFO_RESPONSE_CODE(3)curl_easy_getinfo(3)curl_easy_setopt(3)
mwah π this iconic page is from libcurl, dated 2026-10-12, and it's literally CURLINFO_SCHEME(3) β periodt πβ¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms