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