CURLOPT_PROTOCOLS_STR.3 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .\" generated by cd2nroff 0.1 from CURLOPT_PROTOCOLS_STR.md
  2. .TH CURLOPT_PROTOCOLS_STR 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_PROTOCOLS_STR \- allowed protocols
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS_STR, char *spec);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a string that holds a comma\-separated list of case
  12. insensitive protocol names (URL schemes) to allow in the transfer. This
  13. option allows applications to use libcurl built to support a wide range of
  14. protocols but still limit specific transfers to only be allowed to use a
  15. subset of them. By default, libcurl accepts all protocols it was built with
  16. support for. See also \fICURLOPT_REDIR_PROTOCOLS_STR(3)\fP.
  17. If trying to set a non\-existing protocol or if no matching protocol at all is
  18. set, it returns error.
  19. These are the available protocols:
  20. DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS,
  21. MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP,
  22. SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS
  23. You can set "ALL" as a short\-cut to enable all protocols. Note that by setting
  24. all, you may enable protocols that were not supported the day you write this
  25. but are introduced in a future libcurl version.
  26. \fIcurl_version_info(3)\fP can be used to get a list of all supported
  27. protocols in the current libcurl. \fICURLINFO_SCHEME(3)\fP is the recommended
  28. way to figure out the protocol used in a previous transfer.
  29. .SH DEFAULT
  30. All protocols built\-in
  31. .SH PROTOCOLS
  32. This functionality affects all supported protocols
  33. .SH EXAMPLE
  34. .nf
  35. int main(int argc, char **argv)
  36. {
  37. CURL *curl = curl_easy_init();
  38. if(curl) {
  39. /* pass in the URL from an external source */
  40. curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
  41. /* only allow HTTP, TFTP and SFTP */
  42. curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp");
  43. /* Perform the request */
  44. curl_easy_perform(curl);
  45. }
  46. }
  47. .fi
  48. .SH AVAILABILITY
  49. Added in curl 7.85.0
  50. .SH RETURN VALUE
  51. Returns CURLE_UNKNOWN_OPTION if the option is not implemented,
  52. CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled,
  53. CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK.
  54. .SH SEE ALSO
  55. .BR CURLINFO_SCHEME (3),
  56. .BR CURLOPT_DEFAULT_PROTOCOL (3),
  57. .BR CURLOPT_REDIR_PROTOCOLS_STR (3),
  58. .BR CURLOPT_URL (3),
  59. .BR curl_version_info (3)