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