GNURLOPT_PROTOCOLS(3)
π GNURLOPT_PROTOCOLS(3) π
okay so this page lives in the curl_easy_setopt options family (gnurl edition, we're fancy), and it's all about which protocols your transfer is allowed to touch π
β¨ NAME β¨
CURLOPT_PROTOCOLS β set allowed protocols, i.e. the VIP list at the door and your transfer is NOT getting in unless it's on it π
πΈ SYNOPSIS πΈ
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS, long
bitmask);
π¦ DESCRIPTION π¦
so bestie, you pass a long that holds a bitmask made of CURLPROTO_* defines. If you use it, that bitmask limits what protocols libcurl may use in the transfer. the whole point? you can have a libcurl built to support a wide range of protocols but still limit specific transfers to only be allowed to use a subset of them. iconique, right? π«Ά
by default libcurl will accept all protocols it supports (CURLPROTO_ALL). also go look at CURLOPT_REDIR_PROTOCOLS(3) while you're at it π
these are the available protocol defines, no cap, the whole list:
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
β DEFAULT β
all protocols built-in β like, everything the build came with, go wild π
π§ PROTOCOLS π§
All β every protocol, periodt.
π₯ EXAMPLE π₯
here's the vibe, literally copy-paste energy:
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,
CURLPROTO_HTTP | CURLPROTO_TFTP | CURLPROTO_SFTP);
/* Perform the request */
curl_easy_perform(curl);
}
see how those three get OR'd together with |? that's the bitmask slay π
π AVAILABILITY π
added in 7.19.4 β vintage but still iconic π
π RETURN VALUE π
returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple as that, no drama β¨
π SEE ALSO π
ngl, this one's short but she matters β restricting protocols is like, the main character energy of safe transfers π₯
okay that's the whole page bestie, love that for us π β this gem is from libcurl 7.37.0, dated 19 Jun 2014, and it's the GNURLOPT_PROTOCOLS(3) manual page signing off ππ¦
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms