CURLOPT_DEFAULT_PROTOCOL.3 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. .\" generated by cd2nroff 0.1 from CURLOPT_DEFAULT_PROTOCOL.md
  2. .TH CURLOPT_DEFAULT_PROTOCOL 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_DEFAULT_PROTOCOL \- default protocol to use if the URL is missing a
  5. scheme name
  6. .SH SYNOPSIS
  7. .nf
  8. #include <curl/curl.h>
  9. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEFAULT_PROTOCOL,
  10. char *protocol);
  11. .fi
  12. .SH DESCRIPTION
  13. This option tells libcurl to use \fIprotocol\fP if the URL is missing a scheme
  14. name.
  15. Use one of these protocol (scheme) names:
  16. dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3,
  17. pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
  18. An unknown or unsupported protocol causes error
  19. \fICURLE_UNSUPPORTED_PROTOCOL\fP when libcurl parses a URL without a
  20. scheme. Parsing happens when \fIcurl_easy_perform(3)\fP or
  21. \fIcurl_multi_perform(3)\fP is called. The protocol set supported by libcurl
  22. vary depending on how it was built. Use \fIcurl_version_info(3)\fP if you need
  23. a list of protocol names supported by the build of libcurl that you are using.
  24. This option does not change the default proxy protocol (http).
  25. Without this option libcurl would make a guess based on the host, see
  26. \fICURLOPT_URL(3)\fP for details.
  27. The application does not have to keep the string around after setting this
  28. option.
  29. .SH DEFAULT
  30. NULL (make a guess based on the host)
  31. .SH PROTOCOLS
  32. This functionality affects all supported protocols
  33. .SH EXAMPLE
  34. .nf
  35. int main(void)
  36. {
  37. CURL *curl = curl_easy_init();
  38. if(curl) {
  39. /* set a URL without a scheme */
  40. curl_easy_setopt(curl, CURLOPT_URL, "example.com");
  41. /* set the default protocol (scheme) for schemeless URLs */
  42. curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  43. /* Perform the request */
  44. curl_easy_perform(curl);
  45. }
  46. }
  47. .fi
  48. .SH AVAILABILITY
  49. Added in curl 7.45.0
  50. .SH RETURN VALUE
  51. CURLE_OK if the option is supported.
  52. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  53. CURLE_UNKNOWN_OPTION if the option is not supported.
  54. .SH SEE ALSO
  55. .BR CURLINFO_PROTOCOL (3),
  56. .BR CURLINFO_SCHEME (3),
  57. .BR CURLOPT_URL (3)