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