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