2
0

CURLOPT_URL.3 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_URL 3 "17 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_URL \- URL for this transfer
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass in a pointer to the \fIURL\fP to work with. The parameter should be a
  35. char * to a null-terminated string which must be URL-encoded in the following
  36. format:
  37. scheme://host:port/path
  38. For a greater explanation of the format please see RFC 3986.
  39. libcurl does not validate the syntax or use this variable until the transfer is
  40. issued. Even if you set a crazy value here, \fIcurl_easy_setopt(3)\fP will
  41. still return \fICURLE_OK\fP.
  42. If the given URL is missing a scheme name (such as "http://" or "ftp://" etc)
  43. then libcurl will make a guess based on the host. If the outermost sub-domain
  44. name matches DICT, FTP, IMAP, LDAP, POP3 or SMTP then that protocol will be
  45. used, otherwise HTTP will be used. Since 7.45.0 guessing can be disabled by
  46. setting a default protocol, see \fICURLOPT_DEFAULT_PROTOCOL(3)\fP for details.
  47. Should the protocol, either that specified by the scheme or deduced by libcurl
  48. from the host name, not be supported by libcurl then
  49. \fICURLE_UNSUPPORTED_PROTOCOL\fP will be returned from either the
  50. \fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP functions when you
  51. call them. Use \fIcurl_version_info(3)\fP for detailed information of which
  52. protocols are supported by the build of libcurl you are using.
  53. \fICURLOPT_PROTOCOLS(3)\fP can be used to limit what protocols libcurl will
  54. use for this transfer, independent of what libcurl has been compiled to
  55. support. That may be useful if you accept the URL from an external source and
  56. want to limit the accessibility.
  57. The \fICURLOPT_URL(3)\fP string will be ignored if \fICURLOPT_CURLU(3)\fP is
  58. set.
  59. \fICURLOPT_URL(3)\fP or \fICURLOPT_CURLU(3)\fP \fBmust\fP be set before a
  60. transfer is started.
  61. The application does not have to keep the string around after setting this
  62. option.
  63. .SH ENCODING
  64. The string pointed to in the \fICURLOPT_URL(3)\fP argument is generally
  65. expected to be a sequence of characters using an ASCII compatible encoding.
  66. If libcurl is built with IDN support, the server name part of the URL can use
  67. an "international name" by using the current encoding (according to locale) or
  68. UTF-8 (when winidn is used; or a Windows Unicode build using libidn2).
  69. If libcurl is built without IDN support, the server name is used exactly as
  70. specified when passed to the name resolver functions.
  71. .SH DEFAULT
  72. There is no default URL. If this option is not set, no transfer can be
  73. performed.
  74. .SH SECURITY CONCERNS
  75. Applications may at times find it convenient to allow users to specify URLs
  76. for various purposes and that string would then end up fed to this option.
  77. Getting a URL from an external untrusted party will bring reasons for several
  78. security concerns:
  79. If you have an application that runs as or in a server application, getting an
  80. unfiltered URL can easily trick your application to access a local resource
  81. instead of a remote. Protecting yourself against localhost accesses is hard
  82. when accepting user provided URLs.
  83. Such custom URLs can also access other ports than you planned as port numbers
  84. are part of the regular URL format. The combination of a local host and a
  85. custom port number can allow external users to play tricks with your local
  86. services.
  87. Accepting external URLs may also use other protocols than http:// or other
  88. common ones. Restrict what accept with \fICURLOPT_PROTOCOLS(3)\fP.
  89. User provided URLs can also be made to point to sites that redirect further on
  90. (possibly to other protocols too). Consider your
  91. \fICURLOPT_FOLLOWLOCATION(3)\fP and \fICURLOPT_REDIR_PROTOCOLS(3)\fP settings.
  92. .SH PROTOCOLS
  93. All
  94. .SH EXAMPLE
  95. .nf
  96. CURL *curl = curl_easy_init();
  97. if(curl) {
  98. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  99. curl_easy_perform(curl);
  100. }
  101. .fi
  102. .SH AVAILABILITY
  103. POP3 and SMTP were added in 7.31.0
  104. .SH RETURN VALUE
  105. Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insufficient
  106. heap space.
  107. Note that \fIcurl_easy_setopt(3)\fP will not actually parse the given string so
  108. given a bad URL, it will not be detected until \fIcurl_easy_perform(3)\fP or
  109. similar is called.
  110. .SH "SEE ALSO"
  111. .BR CURLOPT_VERBOSE "(3), " CURLOPT_PROTOCOLS "(3), "
  112. .BR CURLOPT_FORBID_REUSE "(3), " CURLOPT_FRESH_CONNECT "(3), "
  113. .BR curl_easy_perform "(3), "
  114. .BR CURLINFO_REDIRECT_URL "(3), " CURLOPT_PATH_AS_IS "(3), " CURLOPT_CURLU "(3), "