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