xref: /curl/docs/libcurl/opts/CURLOPT_PROTOCOLS.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PROTOCOLS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_DEFAULT_PROTOCOL (3)
9  - CURLOPT_REDIR_PROTOCOLS (3)
10  - CURLOPT_URL (3)
11Protocol:
12  - All
13---
14
15# NAME
16
17CURLOPT_PROTOCOLS - allowed protocols
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS, long bitmask);
25~~~
26
27# DESCRIPTION
28
29This option is deprecated. We strongly recommend using
30CURLOPT_PROTOCOLS_STR(3) instead because this option cannot control all
31available protocols!
32
33Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this bitmask
34limits what protocols libcurl may use in the transfer. This allows you to have
35a libcurl built to support a wide range of protocols but still limit specific
36transfers to only be allowed to use a subset of them. By default libcurl
37accepts all protocols it supports (*CURLPROTO_ALL*). See also
38CURLOPT_REDIR_PROTOCOLS(3).
39
40These are the available protocol defines:
41~~~c
42CURLPROTO_DICT
43CURLPROTO_FILE
44CURLPROTO_FTP
45CURLPROTO_FTPS
46CURLPROTO_GOPHER
47CURLPROTO_HTTP
48CURLPROTO_HTTPS
49CURLPROTO_IMAP
50CURLPROTO_IMAPS
51CURLPROTO_LDAP
52CURLPROTO_LDAPS
53CURLPROTO_POP3
54CURLPROTO_POP3S
55CURLPROTO_RTMP
56CURLPROTO_RTMPE
57CURLPROTO_RTMPS
58CURLPROTO_RTMPT
59CURLPROTO_RTMPTE
60CURLPROTO_RTMPTS
61CURLPROTO_RTSP
62CURLPROTO_SCP
63CURLPROTO_SFTP
64CURLPROTO_SMB
65CURLPROTO_SMBS
66CURLPROTO_SMTP
67CURLPROTO_SMTPS
68CURLPROTO_TELNET
69CURLPROTO_TFTP
70~~~
71
72# DEFAULT
73
74All protocols built-in.
75
76# EXAMPLE
77
78~~~c
79int main(int argc, char **argv)
80{
81  CURL *curl = curl_easy_init();
82  if(curl) {
83    /* pass in the URL from an external source */
84    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
85
86    /* only allow HTTP, TFTP and SFTP */
87    curl_easy_setopt(curl, CURLOPT_PROTOCOLS,
88                     CURLPROTO_HTTP | CURLPROTO_TFTP | CURLPROTO_SFTP);
89
90    /* Perform the request */
91    curl_easy_perform(curl);
92  }
93}
94~~~
95
96# AVAILABILITY
97
98Added in 7.19.4. Deprecated since 7.85.0.
99
100# RETURN VALUE
101
102Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
103