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