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 protocols in
53the current libcurl. CURLINFO_SCHEME(3) is the recommended way to figure out
54the protocol used in a previous transfer.
55
56Using this option multiple times makes the last set string override the
57previous ones. Set it to NULL to restore to the internal default.
58
59# DEFAULT
60
61All protocols built-in
62
63# %PROTOCOLS%
64
65# EXAMPLE
66
67~~~c
68int main(int argc, char **argv)
69{
70  CURL *curl = curl_easy_init();
71  if(curl) {
72    /* pass in the URL from an external source */
73    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
74
75    /* only allow HTTP, TFTP and SFTP */
76    curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp");
77
78    /* Perform the request */
79    curl_easy_perform(curl);
80  }
81}
82~~~
83
84# %AVAILABILITY%
85
86# RETURN VALUE
87
88Returns CURLE_UNKNOWN_OPTION if the option is not implemented,
89CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled,
90CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK.
91