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