Revert "Update to 7.40.1"
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_URL.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2014, 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 http://curl.haxx.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 .\" **************************************************************************
22 .\"
23 .TH CURLOPT_URL 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
24 .SH NAME
25 CURLOPT_URL \- provide the URL to use in the reqest
26 .SH SYNOPSIS
27 #include <curl/curl.h>
28
29 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL);
30 .SH DESCRIPTION
31 Pass in a pointer to the \fIURL\fP to work with. The parameter should be a
32 char * to a zero terminated string which must be URL-encoded in the following
33 format:
34
35 scheme://host:port/path
36
37 For a greater explanation of the format please see RFC3986.
38
39 libcurl doesn't 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
43 If the given URL lacks the scheme (such as "http://" or "ftp://" etc) then
44 libcurl will attempt to resolve the protocol based on one of the following
45 given host names: HTTP, FTP, DICT, LDAP, IMAP, POP3 or SMTP
46
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
54 \fICURLOPT_PROTOCOLS(3)\fP can be used to limit what protocols libcurl will
55 use for this transfer, independent of what libcurl has been compiled to
56 support. That may be useful if you accept the URL from an external source and
57 want to limit the accessibility.
58
59 \fICURLOPT_URL(3)\fP is the only option that \fBmust\fP be set before a
60 transfer is started.
61
62 The host part of the URL contains the address of the server that you want to
63 connect to. This can be the fully qualified domain name of the server, the
64 local network name of the machine on your network or the IP address of the
65 server or machine represented by either an IPv4 or IPv6 address. For example:
66
67 http://www.example.com/
68
69 http://hostname/
70
71 http://192.168.0.1/
72
73 http://[2001:1890:1112:1::20]/
74
75 It is also possible to specify the user name, password and any supported login
76 options as part of the host, for the following protocols, when connecting to
77 servers that require authentication:
78
79 http://user:password@www.example.com
80
81 ftp://user:password@ftp.example.com
82
83 imap://user:password;options@mail.example.com
84
85 pop3://user:password;options@mail.example.com
86
87 smtp://user:password;options@mail.example.com
88
89 At present only IMAP, POP3 and SMTP support login options as part of the host.
90 For more information about the login options in URL syntax please see RFC2384,
91 RFC5092 and IETF draft draft-earhart-url-smtp-00.txt (Added in 7.31.0).
92
93 The port is optional and when not specified libcurl will use the default port
94 based on the determined or specified protocol: 80 for HTTP, 21 for FTP and 25
95 for SMTP, etc. The following examples show how to specify the port:
96
97 http://www.example.com:8080/ - This will connect to a web server using port
98 8080 rather than 80.
99
100 smtp://mail.example.com:587/ - This will connect to a SMTP server on the
101 alternative mail port.
102
103 The path part of the URL is protocol specific and whilst some examples are
104 given below this list is not conclusive:
105
106 .IP HTTP
107 The path part of a HTTP request specifies the file to retrieve and from what
108 directory. If the directory is not specified then the web server's root
109 directory is used. If the file is omitted then the default document will be
110 retrieved for either the directory specified or the root directory. The exact
111 resource returned for each URL is entirely dependent on the server's
112 configuration.
113
114 http://www.example.com - This gets the main page from the web server.
115
116 http://www.example.com/index.html - This returns the main page by explicitly
117 requesting it.
118
119 http://www.example.com/contactus/ - This returns the default document from
120 the contactus directory.
121
122 .IP FTP
123 The path part of an FTP request specifies the file to retrieve and from what
124 directory. If the file part is omitted then libcurl downloads the directory
125 listing for the directory specified. If the directory is omitted then
126 the directory listing for the root / home directory will be returned.
127
128 ftp://ftp.example.com - This retrieves the directory listing for the root
129 directory.
130
131 ftp://ftp.example.com/readme.txt - This downloads the file readme.txt from the
132 root directory.
133
134 ftp://ftp.example.com/libcurl/readme.txt - This downloads readme.txt from the
135 libcurl directory.
136
137 ftp://user:password@ftp.example.com/readme.txt - This retrieves the readme.txt
138 file from the user's home directory. When a username and password is
139 specified, everything that is specified in the path part is relative to the
140 user's home directory. To retrieve files from the root directory or a
141 directory underneath the root directory then the absolute path must be
142 specified by prepending an additional forward slash to the beginning of the
143 path.
144
145 ftp://user:password@ftp.example.com//readme.txt - This retrieves the readme.txt
146 from the root directory when logging in as a specified user.
147
148 .IP SMTP
149 The path part of a SMTP request specifies the host name to present during
150 communication with the mail server. If the path is omitted then libcurl will
151 attempt to resolve the local computer's host name. However, this may not
152 return the fully qualified domain name that is required by some mail servers
153 and specifying this path allows you to set an alternative name, such as
154 your machine's fully qualified domain name, which you might have obtained
155 from an external function such as gethostname or getaddrinfo.
156
157 smtp://mail.example.com - This connects to the mail server at example.com and
158 sends your local computer's host name in the HELO / EHLO command.
159
160 smtp://mail.example.com/client.example.com - This will send client.example.com in
161 the HELO / EHLO command to the mail server at example.com.
162
163 .IP POP3
164 The path part of a POP3 request specifies the message ID to retrieve. If the
165 ID is not specified then a list of waiting messages is returned instead.
166
167 pop3://user:password@mail.example.com - This lists the available messages for
168 the user
169
170 pop3://user:password@mail.example.com/1 - This retrieves the first message for
171 the user
172
173 .IP IMAP
174 The path part of an IMAP request not only specifies the mailbox to list (Added
175 in 7.30.0) or select, but can also be used to check the UIDVALIDITY of the
176 mailbox, to specify the UID, SECTION (Added in 7.30.0) and PARTIAL octets
177 (Added in 7.37.0) of the message to fetch and to specify what messages to
178 search for (Added in 7.37.0).
179
180 imap://user:password@mail.example.com - Performs a top level folder list
181
182 imap://user:password@mail.example.com/INBOX - Performs a folder list on the
183 user's inbox
184
185 imap://user:password@mail.example.com/INBOX/;UID=1 - Selects the user's inbox
186 and fetches message 1
187
188 imap://user:password@mail.example.com/INBOX;UIDVALIDITY=50/;UID=2 - Selects
189 the user's inbox, checks the UIDVALIDITY of the mailbox is 50 and fetches
190 message 2 if it is
191
192 imap://user:password@mail.example.com/INBOX/;UID=3/;SECTION=TEXT - Selects the
193 user's inbox and fetches the text portion of message 3
194
195 imap://user:password@mail.example.com/INBOX/;UID=4/;PARTIAL=0.1024 - Selects
196 the user's inbox and fetches the first 1024 octets of message 4
197
198 imap://user:password@mail.example.com/INBOX?NEW - Selects the user's inbox and
199 checks for NEW messages
200
201 imap://user:password@mail.example.com/INBOX?SUBJECT%20shadows - Selects the
202 user's inbox and searches for messages containing "shadows" in the subject
203 line
204
205 For more information about the individual components of an IMAP URL please
206 see RFC5092.
207
208 .IP SCP
209 The path part of a SCP request specifies the file to retrieve and from what
210 directory. The file part may not be omitted. The file is taken as an absolute
211 path from the root directory on the server. To specify a path relative to the
212 user's home directory on the server, prepend ~/ to the path portion.  If the
213 user name is not embedded in the URL, it can be set with the
214 \fICURLOPT_USERPWD(3)\fP or \fICURLOPT_USERNAME(3)\fP option.
215
216 scp://user@example.com/etc/issue - This specifies the file /etc/issue
217
218 scp://example.com/~/my-file - This specifies the file my-file in the
219 user's home directory on the server
220
221 .IP SFTP
222 The path part of a SFTP request specifies the file to retrieve and from what
223 directory. If the file part is omitted then libcurl downloads the directory
224 listing for the directory specified.  If the path ends in a / then a directory
225 listing is returned instead of a file.  If the path is omitted entirely then
226 the directory listing for the root / home directory will be returned.  If the
227 user name is not embedded in the URL, it can be set with the
228 \fICURLOPT_USERPWD(3)\fP or \fICURLOPT_USERNAME(3)\fP option.
229
230 sftp://user:password@example.com/etc/issue - This specifies the file
231 /etc/issue
232
233 sftp://user@example.com/~/my-file - This specifies the file my-file in the
234 user's home directory
235
236 sftp://ssh.example.com/~/Documents/ - This requests a directory listing
237 of the Documents directory under the user's home directory
238
239 .IP LDAP
240 The path part of a LDAP request can be used to specify the: Distinguished
241 Name, Attributes, Scope, Filter and Extension for a LDAP search. Each field
242 is separated by a question mark and when that field is not required an empty
243 string with the question mark separator should be included.
244
245 ldap://ldap.example.com/o=My%20Organisation - This will perform a LDAP search
246 with the DN as My Organisation.
247
248 ldap://ldap.example.com/o=My%20Organisation?postalAddress - This will perform
249 the same search but will only return postalAddress attributes.
250
251 ldap://ldap.example.com/?rootDomainNamingContext - This specifies an empty DN
252 and requests information about the rootDomainNamingContext attribute for an
253 Active Directory server.
254
255 For more information about the individual components of a LDAP URL please
256 see RFC4516.
257 .IP RTMP
258 There's no official URL spec for RTMP so libcurl uses the URL syntax supported
259 by the underlying librtmp library. It has a syntax where it wants a
260 traditional URL, followed by a space and a series of space-separated
261 name=value pairs.
262
263 While space is not typically a "legal" letter, libcurl accepts them. When a
264 user wants to pass in a '#' (hash) character it will be treated as a fragment
265 and get cut off by libcurl if provided literally. You will instead have to
266 escape it by providing it as backslash and its ASCII value in hexadecimal:
267 "\\23".
268 .SH DEFAULT
269 There is no default URL. If this option isn't set, no transfer can be
270 performed.
271 .SH PROTOCOLS
272 All
273 .SH EXAMPLE
274 .nf
275    curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
276 .SH AVAILABILITY
277 POP3 and SMTP added in 7.31.0
278 .SH RETURN VALUE
279 Returns CURLE_OK on success or
280 CURLE_OUT_OF_MEMORY if there was insufficient heap space.
281 .SH "SEE ALSO"
282 .BR CURLOPT_VERBOSE "(3), " CURLOPT_PROTOCOLS "(3), "
283 .BR curl_easy_perform "(3)"