1CURLOPT_URL(3)             curl_easy_setopt options             CURLOPT_URL(3)
2
3
4

NAME

6       CURLOPT_URL - provide the URL to use in the request
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL);
12

DESCRIPTION

14       Pass  in  a  pointer to the URL to work with. The parameter should be a
15       char * to a null-terminated string which must  be  URL-encoded  in  the
16       following format:
17
18       scheme://host:port/path
19
20       For a greater explanation of the format please see RFC3986.
21
22       libcurl  doesn't  validate  the  syntax  or use this variable until the
23       transfer is issued. Even if you set a crazy value  here,  curl_easy_se‐
24       topt(3) will still return CURLE_OK.
25
26       If  the  given  URL  is  missing  a  scheme  name (such as "http://" or
27       "ftp://" etc) then libcurl will make a guess based on the host. If  the
28       outermost  sub-domain  name matches DICT, FTP, IMAP, LDAP, POP3 or SMTP
29       then that protocol will be used, otherwise HTTP  will  be  used.  Since
30       7.45.0 guessing can be disabled by setting a default protocol, see CUR‐
31       LOPT_DEFAULT_PROTOCOL(3) for details.
32
33       Should the protocol, either that specified by the scheme or deduced  by
34       libcurl  from the host name, not be supported by libcurl then CURLE_UN‐
35       SUPPORTED_PROTOCOL will be  returned  from  either  the  curl_easy_per‐
36       form(3)  or  curl_multi_perform(3)  functions  when  you call them. Use
37       curl_version_info(3) for detailed information of  which  protocols  are
38       supported by the build of libcurl you are using.
39
40       CURLOPT_PROTOCOLS(3)  can  be used to limit what protocols libcurl will
41       use for this transfer, independent of what libcurl has been compiled to
42       support.  That  may  be  useful  if you accept the URL from an external
43       source and want to limit the accessibility.
44
45       The CURLOPT_URL(3) string will be ignored if CURLOPT_CURLU(3) is set.
46
47       CURLOPT_URL(3) or CURLOPT_CURLU(3) must be set  before  a  transfer  is
48       started.
49
50       The  application  does not have to keep the string around after setting
51       this option.
52

ENCODING

54       The string pointed to in the CURLOPT_URL(3) argument is  generally  ex‐
55       pected  to be a sequence of characters using an ASCII compatible encod‐
56       ing.
57
58       If libcurl is built with IDN support, the server name part of  the  URL
59       can  use an "international name" by using the current encoding (accord‐
60       ing to locale) or UTF-8 (when winidn is used).
61
62       If libcurl is built without IDN support, the server name  is  used  ex‐
63       actly as specified when passed to the name resolver functions.
64

DEFAULT

66       There  is  no default URL. If this option isn't set, no transfer can be
67       performed.
68

SECURITY CONCERNS

70       Applications may at times find it convenient to allow users to  specify
71       URLs for various purposes and that string would then end up fed to this
72       option.
73
74       Getting a URL from an external untrusted party will bring  reasons  for
75       several security concerns:
76
77       If  you  have  an  application that runs as or in a server application,
78       getting an unfiltered URL can easily trick your application to access a
79       local  resource instead of a remote. Protecting yourself against local‐
80       host accesses is very hard when accepting user provided URLs.
81
82       Such custom URLs can also access other ports than you planned  as  port
83       numbers  are part of the regular URL format. The combination of a local
84       host and a custom port number can allow external users to  play  tricks
85       with your local services.
86
87       Accepting  external  URLs  may also use other protocols than http:// or
88       other common ones. Restrict what accept with CURLOPT_PROTOCOLS(3).
89
90       User provided URLs can also be made to point  to  sites  that  redirect
91       further  on  (possibly  to  other  protocols  too).  Consider your CUR‐
92       LOPT_FOLLOWLOCATION(3) and CURLOPT_REDIR_PROTOCOLS(3) settings.
93

PROTOCOLS

95       All
96

EXAMPLE

98       CURL *curl = curl_easy_init();
99       if(curl) {
100         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
101
102         curl_easy_perform(curl);
103       }
104

AVAILABILITY

106       POP3 and SMTP were added in 7.31.0
107

RETURN VALUE

109       Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was  insuf‐
110       ficient heap space.
111
112       Note  that curl_easy_setopt(3) won't actually parse the given string so
113       given a bad URL, it will not be detected until curl_easy_perform(3)  or
114       similar is called.
115

SEE ALSO

117       CURLOPT_VERBOSE(3), CURLOPT_PROTOCOLS(3), CURLOPT_FORBID_REUSE(3), CUR‐
118       LOPT_FRESH_CONNECT(3), curl_easy_perform(3),  CURLINFO_REDIRECT_URL(3),
119       CURLOPT_PATH_AS_IS(3), CURLOPT_CURLU(3),
120
121
122
123libcurl 7.76.1                 December 12, 2020                CURLOPT_URL(3)
Impressum