1CURLOPT_DEFAULT_PROTOCOL(3)curl_easy_setopt optionsCURLOPT_DEFAULT_PROTOCOL(3)
2
3
4

NAME

6       CURLOPT_DEFAULT_PROTOCOL  - default protocol to use if the URL is miss‐
7       ing a scheme name
8

SYNOPSIS

10       #include <curl/curl.h>
11
12       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEFAULT_PROTOCOL,  char
13       *protocol);
14

DESCRIPTION

16       This  option  tells  libcurl  to  use  protocol if the URL is missing a
17       scheme name.
18
19       Use one of these protocol (scheme) names:
20
21       dict, file, ftp, ftps, gopher, http, https, imap, imaps,  ldap,  ldaps,
22       pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
23
24       An  unknown or unsupported protocol causes error CURLE_UNSUPPORTED_PRO‐
25       TOCOL when libcurl  parses  a  schemeless  URL.  Parsing  happens  when
26       curl_easy_perform(3)  or curl_multi_perform(3) is called. The protocols
27       supported by libcurl will vary depending  on  how  it  was  built.  Use
28       curl_version_info(3)  if you need a list of protocol names supported by
29       the build of libcurl that you are using.
30
31       This option does not change the default proxy protocol (http).
32
33       Without this option libcurl would make a guess based on the  host,  see
34       CURLOPT_URL(3) for details.
35
36       The  application  does not have to keep the string around after setting
37       this option.
38

DEFAULT

40       NULL (make a guess based on the host)
41

PROTOCOLS

43       All
44

EXAMPLE

46       curl = curl_easy_init();
47       if(curl) {
48         /* set a URL without a scheme */
49         curl_easy_setopt(curl, CURLOPT_URL, "example.com");
50
51         /* set the default protocol (scheme) for schemeless URLs */
52         curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
53
54         /* Perform the request */
55         curl_easy_perform(curl);
56       }
57

AVAILABILITY

59       Added in 7.45.0
60

RETURN VALUE

62       CURLE_OK if the option is supported.
63
64       CURLE_OUT_OF_MEMORY if there was insufficient heap space.
65
66       CURLE_UNKNOWN_OPTION if the option is not supported.
67

SEE ALSO

69       CURLOPT_URL(3),
70
71
72
73libcurl 7.71.1                  March 23, 2020     CURLOPT_DEFAULT_PROTOCOL(3)
Impressum