1CURLOPT_REDIR_PROTOCOLS(3) curl_easy_setopt options CURLOPT_REDIR_PROTOCOLS(3)
2
3
4
6 CURLOPT_REDIR_PROTOCOLS - protocols allowed to redirect to
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS, long bitmask);
12
14 This option is deprecated. We strongly recommend using CUR‐
15 LOPT_REDIR_PROTOCOLS_STR(3) instead because this option cannot control
16 all available protocols!
17
18 Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this
19 bitmask limits what protocols libcurl may use in a transfer that it
20 follows to in a redirect when CURLOPT_FOLLOWLOCATION(3) is enabled.
21 This allows you to limit specific transfers to only be allowed to use a
22 subset of protocols in redirections.
23
24 Protocols denied by CURLOPT_PROTOCOLS(3) are not overridden by this op‐
25 tion.
26
27 By default libcurl will allow HTTP, HTTPS, FTP and FTPS on redirect
28 (7.65.2). Older versions of libcurl allowed all protocols on redirect
29 except several disabled for security reasons: Since 7.19.4 FILE and SCP
30 are disabled, and since 7.40.0 SMB and SMBS are also disabled. CURL‐
31 PROTO_ALL enables all protocols on redirect, including those disabled
32 for security.
33
34 These are the available protocol defines:
35 CURLPROTO_DICT
36 CURLPROTO_FILE
37 CURLPROTO_FTP
38 CURLPROTO_FTPS
39 CURLPROTO_GOPHER
40 CURLPROTO_HTTP
41 CURLPROTO_HTTPS
42 CURLPROTO_IMAP
43 CURLPROTO_IMAPS
44 CURLPROTO_LDAP
45 CURLPROTO_LDAPS
46 CURLPROTO_POP3
47 CURLPROTO_POP3S
48 CURLPROTO_RTMP
49 CURLPROTO_RTMPE
50 CURLPROTO_RTMPS
51 CURLPROTO_RTMPT
52 CURLPROTO_RTMPTE
53 CURLPROTO_RTMPTS
54 CURLPROTO_RTSP
55 CURLPROTO_SCP
56 CURLPROTO_SFTP
57 CURLPROTO_SMB
58 CURLPROTO_SMBS
59 CURLPROTO_SMTP
60 CURLPROTO_SMTPS
61 CURLPROTO_TELNET
62 CURLPROTO_TFTP
63
65 HTTP, HTTPS, FTP and FTPS (Added in 7.65.2).
66
67 Older versions defaulted to all protocols except FILE, SCP and since
68 7.40.0 SMB and SMBS.
69
71 All
72
74 curl = curl_easy_init();
75 if(curl) {
76 /* pass in the URL from an external source */
77 curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
78
79 /* only allow redirects to HTTP and HTTPS URLs */
80 curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
81 CURLPROTO_HTTP | CURLPROTO_HTTPS);
82
83 /* Perform the request */
84 curl_easy_perform(curl);
85 }
86
88 Added in 7.19.4, before then it would follow all protocols.
89
91 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
92 if not.
93
95 CURLOPT_PROTOCOLS(3),
96
97
98
99libcurl 7.85.0 June 13, 2022 CURLOPT_REDIR_PROTOCOLS(3)