1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_PROTOCOLS_STR 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_SCHEME (3) 9 - CURLOPT_DEFAULT_PROTOCOL (3) 10 - CURLOPT_REDIR_PROTOCOLS_STR (3) 11 - CURLOPT_URL (3) 12 - curl_version_info (3) 13Protocol: 14 - All 15Added-in: 7.85.0 16--- 17 18# NAME 19 20CURLOPT_PROTOCOLS_STR - allowed protocols 21 22# SYNOPSIS 23 24~~~c 25#include <curl/curl.h> 26 27CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS_STR, char *spec); 28~~~ 29 30# DESCRIPTION 31 32Pass a pointer to a string that holds a comma-separated list of case 33insensitive protocol names (URL schemes) to allow in the transfer. This 34option allows applications to use libcurl built to support a wide range of 35protocols but still limit specific transfers to only be allowed to use a 36subset of them. By default, libcurl accepts all protocols it was built with 37support for. See also CURLOPT_REDIR_PROTOCOLS_STR(3). 38 39If trying to set a non-existing protocol or if no matching protocol at all is 40set, it returns error. 41 42These are the available protocols: 43 44DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, 45MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP, 46SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS 47 48You can set "ALL" as a short-cut to enable all protocols. Note that by setting 49all, you may enable protocols that were not supported the day you write this 50but are introduced in a future libcurl version. 51 52curl_version_info(3) can be used to get a list of all supported 53protocols in the current libcurl. CURLINFO_SCHEME(3) is the recommended 54way to figure out the protocol used in a previous transfer. 55 56# DEFAULT 57 58All protocols built-in 59 60# %PROTOCOLS% 61 62# EXAMPLE 63 64~~~c 65int main(int argc, char **argv) 66{ 67 CURL *curl = curl_easy_init(); 68 if(curl) { 69 /* pass in the URL from an external source */ 70 curl_easy_setopt(curl, CURLOPT_URL, argv[1]); 71 72 /* only allow HTTP, TFTP and SFTP */ 73 curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp"); 74 75 /* Perform the request */ 76 curl_easy_perform(curl); 77 } 78} 79~~~ 80 81# %AVAILABILITY% 82 83# RETURN VALUE 84 85Returns CURLE_UNKNOWN_OPTION if the option is not implemented, 86CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled, 87CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK. 88