1CURLOPT_REDIR_PROTOCOLS_STR(c3u)rl_easy_setopt optioCnUsRLOPT_REDIR_PROTOCOLS_STR(3)
2
3
4
6 CURLOPT_REDIR_PROTOCOLS_STR - protocols allowed to redirect to
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS_STR,
12 char *spec);
13
15 Pass a pointer to a string that holds a comma-separated list of case
16 insensitive protocol names (URL schemes). That list limits what proto‐
17 cols libcurl may use in a transfer that it follows to in a redirect
18 when CURLOPT_FOLLOWLOCATION(3) is enabled. This option allows applica‐
19 tions to limit specific transfers to only be allowed to use a subset of
20 protocols in redirections.
21
22 Protocols denied by CURLOPT_PROTOCOLS_STR(3) are not overridden by this
23 option.
24
25 By default libcurl will allow HTTP, HTTPS, FTP and FTPS on redirects
26 (since 7.65.2). Older versions of libcurl allowed all protocols on re‐
27 direct except several disabled for security reasons: Since 7.19.4 FILE
28 and SCP are disabled, and since 7.40.0 SMB and SMBS are also disabled.
29
30 These are the available protocols:
31
32 DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP,
33 LDAPS, MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS,
34 RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS
35
36 You can set "ALL" as a short-cut to enable all protocols. Note that by
37 setting all, you may enable protocols that were not supported the day
38 you write this but are introduced in a future libcurl version.
39
40 If trying to set a non-existing protocol or if no matching protocol at
41 all is set, it returns error.
42
44 HTTP, HTTPS, FTP and FTPS (Added in 7.65.2).
45
46 Older versions defaulted to all protocols except FILE, SCP and since
47 7.40.0 SMB and SMBS.
48
50 All
51
53 curl = curl_easy_init();
54 if(curl) {
55 /* pass in the URL from an external source */
56 curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
57
58 /* only allow redirects to HTTP and HTTPS URLs */
59 curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https");
60
61 /* Perform the request */
62 curl_easy_perform(curl);
63 }
64
66 Added in 7.85.0.
67
69 Returns CURLE_UNKNOWN_OPTION if the option is not implemented,
70 CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or
71 disabled, CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else
72 CURLE_OK.
73
75 CURLOPT_PROTOCOLS_STR(3),
76
77
78
79libcurl 8.0.1 January 02, 2023 CURLOPT_REDIR_PROTOCOLS_STR(3)