1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_REDIR_PROTOCOLS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_SCHEME (3)
9  - CURLOPT_DEFAULT_PROTOCOL (3)
10  - CURLOPT_PROTOCOLS (3)
11  - CURLOPT_REDIR_PROTOCOLS_STR (3)
12Protocol:
13  - HTTP
14---
15
16# NAME
17
18CURLOPT_REDIR_PROTOCOLS - protocols allowed to redirect to
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS, long bitmask);
26~~~
27
28# DESCRIPTION
29
30This option is deprecated. We strongly recommend using
31CURLOPT_REDIR_PROTOCOLS_STR(3) instead because this option cannot
32control all available protocols!
33
34Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this bitmask
35limits what protocols libcurl may use in a transfer that it follows to in a
36redirect when CURLOPT_FOLLOWLOCATION(3) is enabled. This allows you to
37limit specific transfers to only be allowed to use a subset of protocols in
38redirections.
39
40Protocols denied by CURLOPT_PROTOCOLS(3) are not overridden by this
41option.
42
43By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirect (7.65.2).
44*CURLPROTO_ALL* enables all protocols on redirect, including those
45otherwise disabled for security.
46
47These are the available protocol defines:
48~~~c
49CURLPROTO_DICT
50CURLPROTO_FILE
51CURLPROTO_FTP
52CURLPROTO_FTPS
53CURLPROTO_GOPHER
54CURLPROTO_HTTP
55CURLPROTO_HTTPS
56CURLPROTO_IMAP
57CURLPROTO_IMAPS
58CURLPROTO_LDAP
59CURLPROTO_LDAPS
60CURLPROTO_POP3
61CURLPROTO_POP3S
62CURLPROTO_RTMP
63CURLPROTO_RTMPE
64CURLPROTO_RTMPS
65CURLPROTO_RTMPT
66CURLPROTO_RTMPTE
67CURLPROTO_RTMPTS
68CURLPROTO_RTSP
69CURLPROTO_SCP
70CURLPROTO_SFTP
71CURLPROTO_SMB
72CURLPROTO_SMBS
73CURLPROTO_SMTP
74CURLPROTO_SMTPS
75CURLPROTO_TELNET
76CURLPROTO_TFTP
77~~~
78
79# DEFAULT
80
81HTTP, HTTPS, FTP and FTPS (Added in 7.65.2).
82
83Older versions defaulted to all protocols except FILE, SCP and since 7.40.0
84SMB and SMBS.
85
86# EXAMPLE
87
88~~~c
89int main(int argc, char **argv)
90{
91  CURL *curl = curl_easy_init();
92  if(curl) {
93    /* pass in the URL from an external source */
94    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
95
96    /* only allow redirects to HTTP and HTTPS URLs */
97    curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
98                     CURLPROTO_HTTP | CURLPROTO_HTTPS);
99
100    /* Perform the request */
101    curl_easy_perform(curl);
102  }
103}
104~~~
105
106# AVAILABILITY
107
108Added in 7.19.4, before then it would follow all protocols. Deprecated
109since 7.85.0.
110
111# RETURN VALUE
112
113Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
114