1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_REDIR_PROTOCOLS_STR
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_SCHEME (3)
9  - CURLOPT_DEFAULT_PROTOCOL (3)
10  - CURLOPT_PROTOCOLS (3)
11  - CURLOPT_PROTOCOLS_STR (3)
12  - CURLOPT_REDIR_PROTOCOLS (3)
13Protocol:
14  - HTTP
15Added-in: 7.85.0
16---
17
18# NAME
19
20CURLOPT_REDIR_PROTOCOLS_STR - protocols allowed to redirect to
21
22# SYNOPSIS
23
24~~~c
25#include <curl/curl.h>
26
27CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS_STR,
28                          char *spec);
29~~~
30
31# DESCRIPTION
32
33Pass a pointer to a string that holds a comma-separated list of case
34insensitive protocol names (URL schemes). That list limits what protocols
35libcurl may use in a transfer that it follows to in a redirect when
36CURLOPT_FOLLOWLOCATION(3) is enabled. This option allows applications to limit
37specific transfers to only be allowed to use a subset of protocols in
38redirections.
39
40Protocols denied by CURLOPT_PROTOCOLS_STR(3) are not overridden by this
41option.
42
43By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirects (since
447.65.2).
45
46These are the available protocols:
47
48DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS,
49MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP,
50SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS
51
52You can set "ALL" as a short-cut to enable all protocols. Note that by setting
53all, you may enable protocols that were not supported the day you write this
54but are introduced in a future libcurl version.
55
56If trying to set a non-existing protocol or if no matching protocol at all is
57set, it returns error.
58
59Using this option multiple times makes the last set string override the
60previous ones. Set it to NULL to restore to internal default.
61
62The application does not have to keep the string around after setting this
63option.
64
65# DEFAULT
66
67HTTP, HTTPS, FTP and FTPS (Added in 7.65.2).
68
69Older versions defaulted to all protocols except FILE, SCP and since 7.40.0
70SMB and SMBS.
71
72# %PROTOCOLS%
73
74# EXAMPLE
75
76~~~c
77int main(int argc, char **argv)
78{
79  CURL *curl = curl_easy_init();
80  if(curl) {
81    /* pass in the URL from an external source */
82    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
83
84    /* only allow redirects to HTTP and HTTPS URLs */
85    curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https");
86
87    /* Perform the request */
88    curl_easy_perform(curl);
89  }
90}
91~~~
92
93# %AVAILABILITY%
94
95# RETURN VALUE
96
97Returns CURLE_UNKNOWN_OPTION if the option is not implemented,
98CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled,
99CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK.
100