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