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