CURLOPT_PROTOCOLS_STR(3)
okay bestie, welcome to the libcurl Library Functions Manual page for CURLOPT_PROTOCOLS_STR β¨ this is the one that decides which URL schemes your transfer is even allowed to touch, and honestly it's giving security-guard-at-the-club energy π
πΈ NAME πΈ
CURLOPT_PROTOCOLS_STR β allowed protocols, aka the VIP list for your URL schemes π«Ά
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS_STR, char *spec);
π DESCRIPTION π
So what you do is pass a pointer to a string, and that string holds a comma-separated list of protocol names (URL schemes) that are allowed in the transfer. The matching is case insensitive, ngl, so don't stress about caps π₯
This is lowkey iconic because it lets applications use a libcurl that was built to support a whole wide range of protocols, but still limit specific transfers so they're only allowed to use a subset of them. By default, libcurl accepts all protocols it was built with support for. See also CURLOPT_REDIR_PROTOCOLS_STR(3) π
If you try to set a non-existing protocol, or if no matching protocol at all is set, it returns error. No cap, it will simply not let that slide π
These are the available protocols:
DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP,
LDAPS, MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS,
RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS
You can set "ALL" as a short-cut to enable all protocols. But bestie, be aware: by setting all, you may enable protocols that were not supported the day you write this, but are introduced in a future libcurl version π the way that's a future-you problem fr fr
curl_version_info(3) can be used to get a list of all supported protocols in the current libcurl. And CURLINFO_SCHEME(3) is the recommended way to figure out the protocol used in a previous transfer π
Using this option multiple times makes the last set string override the previous ones. Set it to NULL to restore to the internal default π
π DEFAULT π
All protocols built-in β she's generous like that π
π¦ PROTOCOLS π¦
This functionality affects all supported protocols π«
β EXAMPLE β
int main(int argc, char **argv)
{
CURL *curl = curl_easy_init();
if(curl) {
/* pass in the URL from an external source */
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
/* only allow HTTP, TFTP and SFTP */
curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp");
/* Perform the request */
curl_easy_perform(curl);
}
}
π AVAILABILITY π
Added in curl 7.85.0 β a whole era β¨
π RETURN VALUE π
- Returns
CURLE_UNKNOWN_OPTIONif the option is not implemented. - Returns
CURLE_UNSUPPORTED_PROTOCOLif a listed protocol is not supported or disabled. - Returns
CURLE_BAD_FUNCTION_ARGUMENTif no protocol is listed. - Else
CURLE_OKβ slay, we're good π«Ά
π SEE ALSO π
CURLINFO_SCHEME(3), CURLOPT_DEFAULT_PROTOCOL(3), CURLOPT_REDIR_PROTOCOLS_STR(3), CURLOPT_URL(3), curl_version_info(3)
and that's the page, bestie π brought to you by libcurl, dated 2026-10-12, and yes the footer said CURLOPT_PROTOCOLS_STR(3) again because it loves a dramatic entrance π
see you in the next man page, mwah π§π
π¦ 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