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 Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this
15 bitmask limits what protocols libcurl may use in a transfer that it
16 follows to in a redirect when CURLOPT_FOLLOWLOCATION(3) is enabled.
17 This allows you to limit specific transfers to only be allowed to use a
18 subset of protocols in redirections.
19
20 Protocols denied by CURLOPT_PROTOCOLS(3) are not overridden by this op‐
21 tion.
22
23 By default libcurl will allow HTTP, HTTPS, FTP and FTPS on redirect
24 (7.65.2). Older versions of libcurl allowed all protocols on redirect
25 except several disabled for security reasons: Since 7.19.4 FILE and SCP
26 are disabled, and since 7.40.0 SMB and SMBS are also disabled. CURL‐
27 PROTO_ALL enables all protocols on redirect, including those disabled
28 for security.
29
30 These are the available protocol defines:
31 CURLPROTO_DICT
32 CURLPROTO_FILE
33 CURLPROTO_FTP
34 CURLPROTO_FTPS
35 CURLPROTO_GOPHER
36 CURLPROTO_HTTP
37 CURLPROTO_HTTPS
38 CURLPROTO_IMAP
39 CURLPROTO_IMAPS
40 CURLPROTO_LDAP
41 CURLPROTO_LDAPS
42 CURLPROTO_POP3
43 CURLPROTO_POP3S
44 CURLPROTO_RTMP
45 CURLPROTO_RTMPE
46 CURLPROTO_RTMPS
47 CURLPROTO_RTMPT
48 CURLPROTO_RTMPTE
49 CURLPROTO_RTMPTS
50 CURLPROTO_RTSP
51 CURLPROTO_SCP
52 CURLPROTO_SFTP
53 CURLPROTO_SMB
54 CURLPROTO_SMBS
55 CURLPROTO_SMTP
56 CURLPROTO_SMTPS
57 CURLPROTO_TELNET
58 CURLPROTO_TFTP
59
61 HTTP, HTTPS, FTP and FTPS (Added in 7.65.2).
62
63 Older versions defaulted to all protocols except FILE, SCP and since
64 7.40.0 SMB and SMBS.
65
67 All
68
70 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 redirects to HTTP and HTTPS URLs */
76 curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
77 CURLPROTO_HTTP | CURLPROTO_HTTPS);
78
79 /* Perform the request */
80 curl_easy_perform(curl);
81 }
82
84 Added in 7.19.4, before then it would follow all protocols.
85
87 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
88 if not.
89
91 CURLOPT_PROTOCOLS(3),
92
93
94
95libcurl 7.82.0 November 26, 2021 CURLOPT_REDIR_PROTOCOLS(3)