2024-01-17 18:32:44 +08:00
|
|
|
---
|
|
|
|
c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
|
|
|
|
SPDX-License-Identifier: curl
|
|
|
|
Title: CURLOPT_REDIR_PROTOCOLS_STR
|
|
|
|
Section: 3
|
|
|
|
Source: libcurl
|
|
|
|
See-also:
|
|
|
|
- CURLINFO_SCHEME (3)
|
|
|
|
- CURLOPT_DEFAULT_PROTOCOL (3)
|
|
|
|
- CURLOPT_PROTOCOLS (3)
|
|
|
|
- CURLOPT_PROTOCOLS_STR (3)
|
|
|
|
- CURLOPT_REDIR_PROTOCOLS (3)
|
|
|
|
---
|
|
|
|
|
|
|
|
# NAME
|
|
|
|
|
|
|
|
CURLOPT_REDIR_PROTOCOLS_STR - protocols allowed to redirect to
|
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
|
|
|
~~~c
|
2022-06-13 15:30:45 +08:00
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS_STR,
|
|
|
|
char *spec);
|
2024-01-17 18:32:44 +08:00
|
|
|
~~~
|
|
|
|
|
|
|
|
# DESCRIPTION
|
|
|
|
|
2022-06-13 15:30:45 +08:00
|
|
|
Pass a pointer to a string that holds a comma-separated list of case
|
|
|
|
insensitive protocol names (URL schemes). That list limits what protocols
|
|
|
|
libcurl may use in a transfer that it follows to in a redirect when
|
2024-01-17 18:32:44 +08:00
|
|
|
CURLOPT_FOLLOWLOCATION(3) is enabled. This option allows applications to
|
2022-06-13 15:30:45 +08:00
|
|
|
limit specific transfers to only be allowed to use a subset of protocols in
|
|
|
|
redirections.
|
|
|
|
|
2024-01-17 18:32:44 +08:00
|
|
|
Protocols denied by CURLOPT_PROTOCOLS_STR(3) are not overridden by this
|
2022-06-13 15:30:45 +08:00
|
|
|
option.
|
|
|
|
|
2023-08-22 23:40:39 +08:00
|
|
|
By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirects (since
|
|
|
|
7.65.2).
|
2022-06-13 15:30:45 +08:00
|
|
|
|
|
|
|
These are the available protocols:
|
|
|
|
|
|
|
|
DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS,
|
2022-09-14 01:47:18 +08:00
|
|
|
MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP,
|
|
|
|
SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS
|
2022-06-13 15:30:45 +08:00
|
|
|
|
|
|
|
You can set "ALL" as a short-cut to enable all protocols. Note that by setting
|
|
|
|
all, you may enable protocols that were not supported the day you write this
|
|
|
|
but are introduced in a future libcurl version.
|
|
|
|
|
|
|
|
If trying to set a non-existing protocol or if no matching protocol at all is
|
|
|
|
set, it returns error.
|
2024-01-17 18:32:44 +08:00
|
|
|
|
|
|
|
# DEFAULT
|
|
|
|
|
2022-06-13 15:30:45 +08:00
|
|
|
HTTP, HTTPS, FTP and FTPS (Added in 7.65.2).
|
|
|
|
|
|
|
|
Older versions defaulted to all protocols except FILE, SCP and since 7.40.0
|
|
|
|
SMB and SMBS.
|
2024-01-17 18:32:44 +08:00
|
|
|
|
|
|
|
# PROTOCOLS
|
|
|
|
|
2022-06-13 15:30:45 +08:00
|
|
|
All
|
2024-01-17 18:32:44 +08:00
|
|
|
|
|
|
|
# EXAMPLE
|
|
|
|
|
|
|
|
~~~c
|
2023-12-04 17:50:42 +08:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
if(curl) {
|
|
|
|
/* pass in the URL from an external source */
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
2022-06-13 15:30:45 +08:00
|
|
|
|
2023-12-04 17:50:42 +08:00
|
|
|
/* only allow redirects to HTTP and HTTPS URLs */
|
|
|
|
curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https");
|
2022-06-13 15:30:45 +08:00
|
|
|
|
2023-12-04 17:50:42 +08:00
|
|
|
/* Perform the request */
|
|
|
|
curl_easy_perform(curl);
|
|
|
|
}
|
2022-06-13 15:30:45 +08:00
|
|
|
}
|
2024-01-17 18:32:44 +08:00
|
|
|
~~~
|
|
|
|
|
|
|
|
# AVAILABILITY
|
|
|
|
|
2022-06-13 15:30:45 +08:00
|
|
|
Added in 7.85.0.
|
2024-01-17 18:32:44 +08:00
|
|
|
|
|
|
|
# RETURN VALUE
|
|
|
|
|
2022-09-14 01:47:18 +08:00
|
|
|
Returns CURLE_UNKNOWN_OPTION if the option is not implemented,
|
|
|
|
CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled,
|
|
|
|
CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK.
|