1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_DEFAULT_PROTOCOL
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_PROTOCOL (3)
9  - CURLINFO_SCHEME (3)
10  - CURLOPT_URL (3)
11Protocol:
12  - All
13---
14
15# NAME
16
17CURLOPT_DEFAULT_PROTOCOL - default protocol to use if the URL is missing a
18scheme name
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEFAULT_PROTOCOL,
26                          char *protocol);
27~~~
28
29# DESCRIPTION
30
31This option tells libcurl to use *protocol* if the URL is missing a scheme
32name.
33
34Use one of these protocol (scheme) names:
35
36dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3,
37pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
38
39An unknown or unsupported protocol causes error
40*CURLE_UNSUPPORTED_PROTOCOL* when libcurl parses a URL without a
41scheme. Parsing happens when curl_easy_perform(3) or
42curl_multi_perform(3) is called. The protocol set supported by libcurl
43vary depending on how it was built. Use curl_version_info(3) if you need
44a list of protocol names supported by the build of libcurl that you are using.
45
46This option does not change the default proxy protocol (http).
47
48Without this option libcurl would make a guess based on the host, see
49CURLOPT_URL(3) for details.
50
51The application does not have to keep the string around after setting this
52option.
53
54# DEFAULT
55
56NULL (make a guess based on the host)
57
58# EXAMPLE
59
60~~~c
61int main(void)
62{
63  CURL *curl = curl_easy_init();
64  if(curl) {
65    /* set a URL without a scheme */
66    curl_easy_setopt(curl, CURLOPT_URL, "example.com");
67
68    /* set the default protocol (scheme) for schemeless URLs */
69    curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
70
71    /* Perform the request */
72    curl_easy_perform(curl);
73  }
74}
75~~~
76
77# AVAILABILITY
78
79Added in 7.45.0
80
81# RETURN VALUE
82
83CURLE_OK if the option is supported.
84
85CURLE_OUT_OF_MEMORY if there was insufficient heap space.
86
87CURLE_UNKNOWN_OPTION if the option is not supported.
88