1*6236dae4SAndroid Build Coastguard Worker<!-- 2*6236dae4SAndroid Build Coastguard WorkerCopyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard Worker 4*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 5*6236dae4SAndroid Build Coastguard Worker--> 6*6236dae4SAndroid Build Coastguard Worker 7*6236dae4SAndroid Build Coastguard Worker# URL syntax and their use in curl 8*6236dae4SAndroid Build Coastguard Worker 9*6236dae4SAndroid Build Coastguard Worker## Specifications 10*6236dae4SAndroid Build Coastguard Worker 11*6236dae4SAndroid Build Coastguard WorkerThe official "URL syntax" is primarily defined in these two different 12*6236dae4SAndroid Build Coastguard Workerspecifications: 13*6236dae4SAndroid Build Coastguard Worker 14*6236dae4SAndroid Build Coastguard Worker - [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986) (although URL is called 15*6236dae4SAndroid Build Coastguard Worker "URI" in there) 16*6236dae4SAndroid Build Coastguard Worker - [The WHATWG URL Specification](https://url.spec.whatwg.org/) 17*6236dae4SAndroid Build Coastguard Worker 18*6236dae4SAndroid Build Coastguard WorkerRFC 3986 is the earlier one, and curl has always tried to adhere to that one 19*6236dae4SAndroid Build Coastguard Worker(since it shipped in January 2005). 20*6236dae4SAndroid Build Coastguard Worker 21*6236dae4SAndroid Build Coastguard WorkerThe WHATWG URL spec was written later, is incompatible with the RFC 3986 and 22*6236dae4SAndroid Build Coastguard Workerchanges over time. 23*6236dae4SAndroid Build Coastguard Worker 24*6236dae4SAndroid Build Coastguard Worker## Variations 25*6236dae4SAndroid Build Coastguard Worker 26*6236dae4SAndroid Build Coastguard WorkerURL parsers as implemented in browsers, libraries and tools usually opt to 27*6236dae4SAndroid Build Coastguard Workersupport one of the mentioned specifications. Bugs, differences in 28*6236dae4SAndroid Build Coastguard Workerinterpretations and the moving nature of the WHATWG spec does however make it 29*6236dae4SAndroid Build Coastguard Workerunlikely that multiple parsers treat URLs the same way. 30*6236dae4SAndroid Build Coastguard Worker 31*6236dae4SAndroid Build Coastguard Worker## Security 32*6236dae4SAndroid Build Coastguard Worker 33*6236dae4SAndroid Build Coastguard WorkerDue to the inherent differences between URL parser implementations, it is 34*6236dae4SAndroid Build Coastguard Workerconsidered a security risk to mix different implementations and assume the 35*6236dae4SAndroid Build Coastguard Workersame behavior. 36*6236dae4SAndroid Build Coastguard Worker 37*6236dae4SAndroid Build Coastguard WorkerFor example, if you use one parser to check if a URL uses a good hostname or 38*6236dae4SAndroid Build Coastguard Workerthe correct auth field, and then pass on that same URL to a *second* parser, 39*6236dae4SAndroid Build Coastguard Workerthere is always a risk it treats the same URL differently. There is no right 40*6236dae4SAndroid Build Coastguard Workerand wrong in URL land, only differences of opinions. 41*6236dae4SAndroid Build Coastguard Worker 42*6236dae4SAndroid Build Coastguard Workerlibcurl offers a separate API to its URL parser for this reason, among others. 43*6236dae4SAndroid Build Coastguard Worker 44*6236dae4SAndroid Build Coastguard WorkerApplications may at times find it convenient to allow users to specify URLs 45*6236dae4SAndroid Build Coastguard Workerfor various purposes and that string would then end up fed to curl. Getting a 46*6236dae4SAndroid Build Coastguard WorkerURL from an external untrusted party and using it with curl brings several 47*6236dae4SAndroid Build Coastguard Workersecurity concerns: 48*6236dae4SAndroid Build Coastguard Worker 49*6236dae4SAndroid Build Coastguard Worker1. If you have an application that runs as or in a server application, getting 50*6236dae4SAndroid Build Coastguard Worker an unfiltered URL can trick your application to access a local resource 51*6236dae4SAndroid Build Coastguard Worker instead of a remote resource. Protecting yourself against localhost accesses 52*6236dae4SAndroid Build Coastguard Worker is hard when accepting user provided URLs. 53*6236dae4SAndroid Build Coastguard Worker 54*6236dae4SAndroid Build Coastguard Worker2. Such custom URLs can access other ports than you planned as port numbers 55*6236dae4SAndroid Build Coastguard Worker are part of the regular URL format. The combination of a local host and a 56*6236dae4SAndroid Build Coastguard Worker custom port number can allow external users to play tricks with your local 57*6236dae4SAndroid Build Coastguard Worker services. 58*6236dae4SAndroid Build Coastguard Worker 59*6236dae4SAndroid Build Coastguard Worker3. Such a URL might use other schemes than you thought of or planned for. 60*6236dae4SAndroid Build Coastguard Worker 61*6236dae4SAndroid Build Coastguard Worker## "RFC 3986 plus" 62*6236dae4SAndroid Build Coastguard Worker 63*6236dae4SAndroid Build Coastguard Workercurl recognizes a URL syntax that we call "RFC 3986 plus". It is grounded on 64*6236dae4SAndroid Build Coastguard Workerthe well established RFC 3986 to make sure previously written command lines 65*6236dae4SAndroid Build Coastguard Workerand curl using scripts remain working. 66*6236dae4SAndroid Build Coastguard Worker 67*6236dae4SAndroid Build Coastguard Workercurl's URL parser allows a few deviations from the spec in order to 68*6236dae4SAndroid Build Coastguard Workerinter-operate better with URLs that appear in the wild. 69*6236dae4SAndroid Build Coastguard Worker 70*6236dae4SAndroid Build Coastguard Worker### Spaces 71*6236dae4SAndroid Build Coastguard Worker 72*6236dae4SAndroid Build Coastguard WorkerA URL provided to curl cannot contain spaces. They need to be provided URL 73*6236dae4SAndroid Build Coastguard Workerencoded to be accepted in a URL by curl. 74*6236dae4SAndroid Build Coastguard Worker 75*6236dae4SAndroid Build Coastguard WorkerAn exception to this rule: `Location:` response headers that indicate to a 76*6236dae4SAndroid Build Coastguard Workerclient where a resource has been redirected to, sometimes contain spaces. This 77*6236dae4SAndroid Build Coastguard Workeris a violation of RFC 3986 but is fine in the WHATWG spec. curl handles these 78*6236dae4SAndroid Build Coastguard Workerby re-encoding them to `%20`. 79*6236dae4SAndroid Build Coastguard Worker 80*6236dae4SAndroid Build Coastguard Worker### Non-ASCII 81*6236dae4SAndroid Build Coastguard Worker 82*6236dae4SAndroid Build Coastguard WorkerByte values in a provided URL that are outside of the printable ASCII range 83*6236dae4SAndroid Build Coastguard Workerare percent-encoded by curl. 84*6236dae4SAndroid Build Coastguard Worker 85*6236dae4SAndroid Build Coastguard Worker### Multiple slashes 86*6236dae4SAndroid Build Coastguard Worker 87*6236dae4SAndroid Build Coastguard WorkerAn absolute URL always starts with a "scheme" followed by a colon. For all the 88*6236dae4SAndroid Build Coastguard Workerschemes curl supports, the colon must be followed by two slashes according to 89*6236dae4SAndroid Build Coastguard WorkerRFC 3986 but not according to the WHATWG spec - which allows one to infinity 90*6236dae4SAndroid Build Coastguard Workeramount. 91*6236dae4SAndroid Build Coastguard Worker 92*6236dae4SAndroid Build Coastguard Workercurl allows one, two or three slashes after the colon to still be considered a 93*6236dae4SAndroid Build Coastguard Workervalid URL. 94*6236dae4SAndroid Build Coastguard Worker 95*6236dae4SAndroid Build Coastguard Worker### "scheme-less" 96*6236dae4SAndroid Build Coastguard Worker 97*6236dae4SAndroid Build Coastguard Workercurl supports "URLs" that do not start with a scheme. This is not supported by 98*6236dae4SAndroid Build Coastguard Workerany of the specifications. This is a shortcut to entering URLs that was 99*6236dae4SAndroid Build Coastguard Workersupported by browsers early on and has been mimicked by curl. 100*6236dae4SAndroid Build Coastguard Worker 101*6236dae4SAndroid Build Coastguard WorkerBased on what the hostname starts with, curl "guesses" what protocol to use: 102*6236dae4SAndroid Build Coastguard Worker 103*6236dae4SAndroid Build Coastguard Worker - `ftp.` means FTP 104*6236dae4SAndroid Build Coastguard Worker - `dict.` means DICT 105*6236dae4SAndroid Build Coastguard Worker - `ldap.` means LDAP 106*6236dae4SAndroid Build Coastguard Worker - `imap.` means IMAP 107*6236dae4SAndroid Build Coastguard Worker - `smtp.` means SMTP 108*6236dae4SAndroid Build Coastguard Worker - `pop3.` means POP3 109*6236dae4SAndroid Build Coastguard Worker - all other means HTTP 110*6236dae4SAndroid Build Coastguard Worker 111*6236dae4SAndroid Build Coastguard Worker### Globbing letters 112*6236dae4SAndroid Build Coastguard Worker 113*6236dae4SAndroid Build Coastguard WorkerThe curl command line tool supports "globbing" of URLs. It means that you can 114*6236dae4SAndroid Build Coastguard Workercreate ranges and lists using `[N-M]` and `{one,two,three}` sequences. The 115*6236dae4SAndroid Build Coastguard Workerletters used for this (`[]{}`) are reserved in RFC 3986 and can therefore not 116*6236dae4SAndroid Build Coastguard Workerlegitimately be part of such a URL. 117*6236dae4SAndroid Build Coastguard Worker 118*6236dae4SAndroid Build Coastguard WorkerThey are however not reserved or special in the WHATWG specification, so 119*6236dae4SAndroid Build Coastguard Workerglobbing can mess up such URLs. Globbing can be turned off for such occasions 120*6236dae4SAndroid Build Coastguard Worker(using `--globoff`). 121*6236dae4SAndroid Build Coastguard Worker 122*6236dae4SAndroid Build Coastguard Worker# URL syntax details 123*6236dae4SAndroid Build Coastguard Worker 124*6236dae4SAndroid Build Coastguard WorkerA URL may consist of the following components - many of them are optional: 125*6236dae4SAndroid Build Coastguard Worker 126*6236dae4SAndroid Build Coastguard Worker [scheme][divider][userinfo][hostname][port number][path][query][fragment] 127*6236dae4SAndroid Build Coastguard Worker 128*6236dae4SAndroid Build Coastguard WorkerEach component is separated from the following component with a divider 129*6236dae4SAndroid Build Coastguard Workercharacter or string. 130*6236dae4SAndroid Build Coastguard Worker 131*6236dae4SAndroid Build Coastguard WorkerFor example, this could look like: 132*6236dae4SAndroid Build Coastguard Worker 133*6236dae4SAndroid Build Coastguard Worker http://user:[email protected]:80/index.html?foo=bar#top 134*6236dae4SAndroid Build Coastguard Worker 135*6236dae4SAndroid Build Coastguard Worker## Scheme 136*6236dae4SAndroid Build Coastguard Worker 137*6236dae4SAndroid Build Coastguard WorkerThe scheme specifies the protocol to use. A curl build can support a few or 138*6236dae4SAndroid Build Coastguard Workermany different schemes. You can limit what schemes curl should accept. 139*6236dae4SAndroid Build Coastguard Worker 140*6236dae4SAndroid Build Coastguard Workercurl supports the following schemes on URLs specified to transfer. They are 141*6236dae4SAndroid Build Coastguard Workermatched case insensitively: 142*6236dae4SAndroid Build Coastguard Worker 143*6236dae4SAndroid Build Coastguard Worker`dict`, `file`, `ftp`, `ftps`, `gopher`, `gophers`, `http`, `https`, `imap`, 144*6236dae4SAndroid Build Coastguard Worker`imaps`, `ldap`, `ldaps`, `mqtt`, `pop3`, `pop3s`, `rtmp`, `rtmpe`, `rtmps`, 145*6236dae4SAndroid Build Coastguard Worker`rtmpt`, `rtmpte`, `rtmpts`, `rtsp`, `smb`, `smbs`, `smtp`, `smtps`, `telnet`, 146*6236dae4SAndroid Build Coastguard Worker`tftp` 147*6236dae4SAndroid Build Coastguard Worker 148*6236dae4SAndroid Build Coastguard WorkerWhen the URL is specified to identify a proxy, curl recognizes the following 149*6236dae4SAndroid Build Coastguard Workerschemes: 150*6236dae4SAndroid Build Coastguard Worker 151*6236dae4SAndroid Build Coastguard Worker`http`, `https`, `socks4`, `socks4a`, `socks5`, `socks5h`, `socks` 152*6236dae4SAndroid Build Coastguard Worker 153*6236dae4SAndroid Build Coastguard Worker## Userinfo 154*6236dae4SAndroid Build Coastguard Worker 155*6236dae4SAndroid Build Coastguard WorkerThe userinfo field can be used to set username and password for 156*6236dae4SAndroid Build Coastguard Workerauthentication purposes in this transfer. The use of this field is discouraged 157*6236dae4SAndroid Build Coastguard Workersince it often means passing around the password in plain text and is thus a 158*6236dae4SAndroid Build Coastguard Workersecurity risk. 159*6236dae4SAndroid Build Coastguard Worker 160*6236dae4SAndroid Build Coastguard WorkerURLs for IMAP, POP3 and SMTP also support *login options* as part of the 161*6236dae4SAndroid Build Coastguard Workeruserinfo field. They are provided as a semicolon after the password and then 162*6236dae4SAndroid Build Coastguard Workerthe options. 163*6236dae4SAndroid Build Coastguard Worker 164*6236dae4SAndroid Build Coastguard Worker## Hostname 165*6236dae4SAndroid Build Coastguard Worker 166*6236dae4SAndroid Build Coastguard WorkerThe hostname part of the URL contains the address of the server that you want 167*6236dae4SAndroid Build Coastguard Workerto connect to. This can be the fully qualified domain name of the server, the 168*6236dae4SAndroid Build Coastguard Workerlocal network name of the machine on your network or the IP address of the 169*6236dae4SAndroid Build Coastguard Workerserver or machine represented by either an IPv4 or IPv6 address (within 170*6236dae4SAndroid Build Coastguard Workerbrackets). For example: 171*6236dae4SAndroid Build Coastguard Worker 172*6236dae4SAndroid Build Coastguard Worker http://www.example.com/ 173*6236dae4SAndroid Build Coastguard Worker 174*6236dae4SAndroid Build Coastguard Worker http://hostname/ 175*6236dae4SAndroid Build Coastguard Worker 176*6236dae4SAndroid Build Coastguard Worker http://192.168.0.1/ 177*6236dae4SAndroid Build Coastguard Worker 178*6236dae4SAndroid Build Coastguard Worker http://[2001:1890:1112:1::20]/ 179*6236dae4SAndroid Build Coastguard Worker 180*6236dae4SAndroid Build Coastguard Worker### "localhost" 181*6236dae4SAndroid Build Coastguard Worker 182*6236dae4SAndroid Build Coastguard WorkerStarting in curl 7.77.0, curl uses loopback IP addresses for the name 183*6236dae4SAndroid Build Coastguard Worker`localhost`: `127.0.0.1` and `::1`. It does not resolve the name using the 184*6236dae4SAndroid Build Coastguard Workerresolver functions. 185*6236dae4SAndroid Build Coastguard Worker 186*6236dae4SAndroid Build Coastguard WorkerThis is done to make sure the host accessed is truly the localhost - the local 187*6236dae4SAndroid Build Coastguard Workermachine. 188*6236dae4SAndroid Build Coastguard Worker 189*6236dae4SAndroid Build Coastguard Worker### IDNA 190*6236dae4SAndroid Build Coastguard Worker 191*6236dae4SAndroid Build Coastguard WorkerIf curl was built with International Domain Name (IDN) support, it can also 192*6236dae4SAndroid Build Coastguard Workerhandle hostnames using non-ASCII characters. 193*6236dae4SAndroid Build Coastguard Worker 194*6236dae4SAndroid Build Coastguard WorkerWhen built with libidn2, curl uses the IDNA 2008 standard. This is equivalent 195*6236dae4SAndroid Build Coastguard Workerto the WHATWG URL spec, but differs from certain browsers that use IDNA 2003 196*6236dae4SAndroid Build Coastguard WorkerTransitional Processing. The two standards have a huge overlap but differ 197*6236dae4SAndroid Build Coastguard Workerslightly, perhaps most famously in how they deal with the German "double s" 198*6236dae4SAndroid Build Coastguard Worker(`ß`). 199*6236dae4SAndroid Build Coastguard Worker 200*6236dae4SAndroid Build Coastguard WorkerWhen WinIDN is used, curl uses IDNA 2003 Transitional Processing, like the rest 201*6236dae4SAndroid Build Coastguard Workerof Windows. 202*6236dae4SAndroid Build Coastguard Worker 203*6236dae4SAndroid Build Coastguard Worker## Port number 204*6236dae4SAndroid Build Coastguard Worker 205*6236dae4SAndroid Build Coastguard WorkerIf there is a colon after the hostname, that should be followed by the port 206*6236dae4SAndroid Build Coastguard Workernumber to use. 1 - 65535. curl also supports a blank port number field - but 207*6236dae4SAndroid Build Coastguard Workeronly if the URL starts with a scheme. 208*6236dae4SAndroid Build Coastguard Worker 209*6236dae4SAndroid Build Coastguard WorkerIf the port number is not specified in the URL, curl uses a default port 210*6236dae4SAndroid Build Coastguard Workernumber based on the provide scheme: 211*6236dae4SAndroid Build Coastguard Worker 212*6236dae4SAndroid Build Coastguard WorkerDICT 2628, FTP 21, FTPS 990, GOPHER 70, GOPHERS 70, HTTP 80, HTTPS 443, 213*6236dae4SAndroid Build Coastguard WorkerIMAP 132, IMAPS 993, LDAP 369, LDAPS 636, MQTT 1883, POP3 110, POP3S 995, 214*6236dae4SAndroid Build Coastguard WorkerRTMP 1935, RTMPS 443, RTMPT 80, RTSP 554, SCP 22, SFTP 22, SMB 445, SMBS 445, 215*6236dae4SAndroid Build Coastguard WorkerSMTP 25, SMTPS 465, TELNET 23, TFTP 69 216*6236dae4SAndroid Build Coastguard Worker 217*6236dae4SAndroid Build Coastguard Worker# Scheme specific behaviors 218*6236dae4SAndroid Build Coastguard Worker 219*6236dae4SAndroid Build Coastguard Worker## FTP 220*6236dae4SAndroid Build Coastguard Worker 221*6236dae4SAndroid Build Coastguard WorkerThe path part of an FTP request specifies the file to retrieve and from which 222*6236dae4SAndroid Build Coastguard Workerdirectory. If the file part is omitted then libcurl downloads the directory 223*6236dae4SAndroid Build Coastguard Workerlisting for the directory specified. If the directory is omitted then the 224*6236dae4SAndroid Build Coastguard Workerdirectory listing for the root / home directory is returned. 225*6236dae4SAndroid Build Coastguard Worker 226*6236dae4SAndroid Build Coastguard WorkerFTP servers typically put the user in its "home directory" after login, which 227*6236dae4SAndroid Build Coastguard Workerthen differs between users. To explicitly specify the root directory of an FTP 228*6236dae4SAndroid Build Coastguard Workerserver, start the path with double slash `//` or `/%2f` (2F is the hexadecimal 229*6236dae4SAndroid Build Coastguard Workervalue of the ASCII code for the slash). 230*6236dae4SAndroid Build Coastguard Worker 231*6236dae4SAndroid Build Coastguard Worker## FILE 232*6236dae4SAndroid Build Coastguard Worker 233*6236dae4SAndroid Build Coastguard WorkerWhen a `FILE://` URL is accessed on Windows systems, it can be crafted in a 234*6236dae4SAndroid Build Coastguard Workerway so that Windows attempts to connect to a (remote) machine when curl wants 235*6236dae4SAndroid Build Coastguard Workerto read or write such a path. 236*6236dae4SAndroid Build Coastguard Worker 237*6236dae4SAndroid Build Coastguard Workercurl only allows the hostname part of a FILE URL to be one out of these three 238*6236dae4SAndroid Build Coastguard Workeralternatives: `localhost`, `127.0.0.1` or blank ("", zero characters). 239*6236dae4SAndroid Build Coastguard WorkerAnything else makes curl fail to parse the URL. 240*6236dae4SAndroid Build Coastguard Worker 241*6236dae4SAndroid Build Coastguard Worker### Windows-specific FILE details 242*6236dae4SAndroid Build Coastguard Worker 243*6236dae4SAndroid Build Coastguard Workercurl accepts that the FILE URL's path starts with a "drive letter". That is a 244*6236dae4SAndroid Build Coastguard Workersingle letter `a` to `z` followed by a colon or a pipe character (`|`). 245*6236dae4SAndroid Build Coastguard Worker 246*6236dae4SAndroid Build Coastguard WorkerThe Windows operating system itself converts some file accesses to perform 247*6236dae4SAndroid Build Coastguard Workernetwork accesses over SMB/CIFS, through several different file path patterns. 248*6236dae4SAndroid Build Coastguard WorkerThis way, a `file://` URL passed to curl *might* be converted into a network 249*6236dae4SAndroid Build Coastguard Workeraccess inadvertently and unknowingly to curl. This is a Windows feature curl 250*6236dae4SAndroid Build Coastguard Workercannot control or disable. 251*6236dae4SAndroid Build Coastguard Worker 252*6236dae4SAndroid Build Coastguard Worker## IMAP 253*6236dae4SAndroid Build Coastguard Worker 254*6236dae4SAndroid Build Coastguard WorkerThe path part of an IMAP request not only specifies the mailbox to list or 255*6236dae4SAndroid Build Coastguard Workerselect, but can also be used to check the `UIDVALIDITY` of the mailbox, to 256*6236dae4SAndroid Build Coastguard Workerspecify the `UID`, `SECTION` and `PARTIAL` octets of the message to fetch and 257*6236dae4SAndroid Build Coastguard Workerto specify what messages to search for. 258*6236dae4SAndroid Build Coastguard Worker 259*6236dae4SAndroid Build Coastguard WorkerA top level folder list: 260*6236dae4SAndroid Build Coastguard Worker 261*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected] 262*6236dae4SAndroid Build Coastguard Worker 263*6236dae4SAndroid Build Coastguard WorkerA folder list on the user's inbox: 264*6236dae4SAndroid Build Coastguard Worker 265*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX 266*6236dae4SAndroid Build Coastguard Worker 267*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox and fetch message with `uid = 1`: 268*6236dae4SAndroid Build Coastguard Worker 269*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX/;UID=1 270*6236dae4SAndroid Build Coastguard Worker 271*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox and fetch the first message in the mail box: 272*6236dae4SAndroid Build Coastguard Worker 273*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX/;MAILINDEX=1 274*6236dae4SAndroid Build Coastguard Worker 275*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox, check the `UIDVALIDITY` of the mailbox is 50 and 276*6236dae4SAndroid Build Coastguard Workerfetch message 2 if it is: 277*6236dae4SAndroid Build Coastguard Worker 278*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX;UIDVALIDITY=50/;UID=2 279*6236dae4SAndroid Build Coastguard Worker 280*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox and fetch the text portion of message 3: 281*6236dae4SAndroid Build Coastguard Worker 282*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX/;UID=3/;SECTION=TEXT 283*6236dae4SAndroid Build Coastguard Worker 284*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox and fetch the first 1024 octets of message 4: 285*6236dae4SAndroid Build Coastguard Worker 286*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX/;UID=4/;PARTIAL=0.1024 287*6236dae4SAndroid Build Coastguard Worker 288*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox and check for NEW messages: 289*6236dae4SAndroid Build Coastguard Worker 290*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX?NEW 291*6236dae4SAndroid Build Coastguard Worker 292*6236dae4SAndroid Build Coastguard WorkerSelect the user's inbox and search for messages containing "shadows" in the 293*6236dae4SAndroid Build Coastguard Workersubject line: 294*6236dae4SAndroid Build Coastguard Worker 295*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX?SUBJECT%20shadows 296*6236dae4SAndroid Build Coastguard Worker 297*6236dae4SAndroid Build Coastguard WorkerSearching via the query part of the URL `?` is a search request for the 298*6236dae4SAndroid Build Coastguard Workerresults to be returned as message sequence numbers (`MAILINDEX`). It is 299*6236dae4SAndroid Build Coastguard Workerpossible to make a search request for results to be returned as unique ID 300*6236dae4SAndroid Build Coastguard Workernumbers (`UID`) by using a custom curl request via `-X`. `UID` numbers are 301*6236dae4SAndroid Build Coastguard Workerunique per session (and multiple sessions when `UIDVALIDITY` is the same). For 302*6236dae4SAndroid Build Coastguard Workerexample, if you are searching for `"foo bar"` in header+body (`TEXT`) and you 303*6236dae4SAndroid Build Coastguard Workerwant the matching `MAILINDEX` numbers returned then you could search via URL: 304*6236dae4SAndroid Build Coastguard Worker 305*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX?TEXT%20%22foo%20bar%22 306*6236dae4SAndroid Build Coastguard Worker 307*6236dae4SAndroid Build Coastguard WorkerIf you want matching `UID` numbers you have to use a custom request: 308*6236dae4SAndroid Build Coastguard Worker 309*6236dae4SAndroid Build Coastguard Worker imap://user:[email protected]/INBOX -X "UID SEARCH TEXT \"foo bar\"" 310*6236dae4SAndroid Build Coastguard Worker 311*6236dae4SAndroid Build Coastguard WorkerFor more information about IMAP commands please see RFC 9051. For more 312*6236dae4SAndroid Build Coastguard Workerinformation about the individual components of an IMAP URL please see RFC 5092. 313*6236dae4SAndroid Build Coastguard Worker 314*6236dae4SAndroid Build Coastguard Worker* Note old curl versions would `FETCH` by message sequence number when `UID` 315*6236dae4SAndroid Build Coastguard Workerwas specified in the URL. That was a bug fixed in 7.62.0, which added 316*6236dae4SAndroid Build Coastguard Worker`MAILINDEX` to `FETCH` by mail sequence number. 317*6236dae4SAndroid Build Coastguard Worker 318*6236dae4SAndroid Build Coastguard Worker## LDAP 319*6236dae4SAndroid Build Coastguard Worker 320*6236dae4SAndroid Build Coastguard WorkerThe path part of a LDAP request can be used to specify the: Distinguished 321*6236dae4SAndroid Build Coastguard WorkerName, Attributes, Scope, Filter and Extension for a LDAP search. Each field is 322*6236dae4SAndroid Build Coastguard Workerseparated by a question mark and when that field is not required an empty 323*6236dae4SAndroid Build Coastguard Workerstring with the question mark separator should be included. 324*6236dae4SAndroid Build Coastguard Worker 325*6236dae4SAndroid Build Coastguard WorkerSearch for the `DN` as `My Organization`: 326*6236dae4SAndroid Build Coastguard Worker 327*6236dae4SAndroid Build Coastguard Worker ldap://ldap.example.com/o=My%20Organization 328*6236dae4SAndroid Build Coastguard Worker 329*6236dae4SAndroid Build Coastguard Workerthe same search but only return `postalAddress` attributes: 330*6236dae4SAndroid Build Coastguard Worker 331*6236dae4SAndroid Build Coastguard Worker ldap://ldap.example.com/o=My%20Organization?postalAddress 332*6236dae4SAndroid Build Coastguard Worker 333*6236dae4SAndroid Build Coastguard WorkerSearch for an empty `DN` and request information about the 334*6236dae4SAndroid Build Coastguard Worker`rootDomainNamingContext` attribute for an Active Directory server: 335*6236dae4SAndroid Build Coastguard Worker 336*6236dae4SAndroid Build Coastguard Worker ldap://ldap.example.com/?rootDomainNamingContext 337*6236dae4SAndroid Build Coastguard Worker 338*6236dae4SAndroid Build Coastguard WorkerFor more information about the individual components of a LDAP URL please 339*6236dae4SAndroid Build Coastguard Workersee [RFC 4516](https://datatracker.ietf.org/doc/html/rfc4516). 340*6236dae4SAndroid Build Coastguard Worker 341*6236dae4SAndroid Build Coastguard Worker## POP3 342*6236dae4SAndroid Build Coastguard Worker 343*6236dae4SAndroid Build Coastguard WorkerThe path part of a POP3 request specifies the message ID to retrieve. If the 344*6236dae4SAndroid Build Coastguard WorkerID is not specified then a list of waiting messages is returned instead. 345*6236dae4SAndroid Build Coastguard Worker 346*6236dae4SAndroid Build Coastguard Worker## SCP 347*6236dae4SAndroid Build Coastguard Worker 348*6236dae4SAndroid Build Coastguard WorkerThe path part of an SCP URL specifies the path and file to retrieve or 349*6236dae4SAndroid Build Coastguard Workerupload. The file is taken as an absolute path from the root directory on the 350*6236dae4SAndroid Build Coastguard Workerserver. 351*6236dae4SAndroid Build Coastguard Worker 352*6236dae4SAndroid Build Coastguard WorkerTo specify a path relative to the user's home directory on the server, prepend 353*6236dae4SAndroid Build Coastguard Worker`~/` to the path portion. 354*6236dae4SAndroid Build Coastguard Worker 355*6236dae4SAndroid Build Coastguard Worker## SFTP 356*6236dae4SAndroid Build Coastguard Worker 357*6236dae4SAndroid Build Coastguard WorkerThe path part of an SFTP URL specifies the file to retrieve or upload. If the 358*6236dae4SAndroid Build Coastguard Workerpath ends with a slash (`/`) then a directory listing is returned instead of a 359*6236dae4SAndroid Build Coastguard Workerfile. If the path is omitted entirely then the directory listing for the root 360*6236dae4SAndroid Build Coastguard Worker/ home directory is returned. 361*6236dae4SAndroid Build Coastguard Worker 362*6236dae4SAndroid Build Coastguard Worker## SMB 363*6236dae4SAndroid Build Coastguard WorkerThe path part of a SMB request specifies the file to retrieve and from what 364*6236dae4SAndroid Build Coastguard Workershare and directory or the share to upload to and as such, may not be omitted. 365*6236dae4SAndroid Build Coastguard WorkerIf the username is embedded in the URL then it must contain the domain name 366*6236dae4SAndroid Build Coastguard Workerand as such, the backslash must be URL encoded as %2f. 367*6236dae4SAndroid Build Coastguard Worker 368*6236dae4SAndroid Build Coastguard WorkerWhen uploading to SMB, the size of the file needs to be known ahead of time, 369*6236dae4SAndroid Build Coastguard Workermeaning that you can upload a file passed to curl over a pipe like stdin. 370*6236dae4SAndroid Build Coastguard Worker 371*6236dae4SAndroid Build Coastguard Workercurl supports SMB version 1 (only) 372*6236dae4SAndroid Build Coastguard Worker 373*6236dae4SAndroid Build Coastguard Worker## SMTP 374*6236dae4SAndroid Build Coastguard Worker 375*6236dae4SAndroid Build Coastguard WorkerThe path part of a SMTP request specifies the hostname to present during 376*6236dae4SAndroid Build Coastguard Workercommunication with the mail server. If the path is omitted, then libcurl 377*6236dae4SAndroid Build Coastguard Workerattempts to resolve the local computer's hostname. However, this may not 378*6236dae4SAndroid Build Coastguard Workerreturn the fully qualified domain name that is required by some mail servers 379*6236dae4SAndroid Build Coastguard Workerand specifying this path allows you to set an alternative name, such as your 380*6236dae4SAndroid Build Coastguard Workermachine's fully qualified domain name, which you might have obtained from an 381*6236dae4SAndroid Build Coastguard Workerexternal function such as gethostname or getaddrinfo. 382*6236dae4SAndroid Build Coastguard Worker 383*6236dae4SAndroid Build Coastguard WorkerThe default smtp port is 25. Some servers use port 587 as an alternative. 384*6236dae4SAndroid Build Coastguard Worker 385*6236dae4SAndroid Build Coastguard Worker## RTMP 386*6236dae4SAndroid Build Coastguard Worker 387*6236dae4SAndroid Build Coastguard WorkerThere is no official URL spec for RTMP so libcurl uses the URL syntax supported 388*6236dae4SAndroid Build Coastguard Workerby the underlying librtmp library. It has a syntax where it wants a 389*6236dae4SAndroid Build Coastguard Workertraditional URL, followed by a space and a series of space-separated 390*6236dae4SAndroid Build Coastguard Worker`name=value` pairs. 391*6236dae4SAndroid Build Coastguard Worker 392*6236dae4SAndroid Build Coastguard WorkerWhile space is not typically a "legal" letter, libcurl accepts them. When a 393*6236dae4SAndroid Build Coastguard Workeruser wants to pass in a `#` (hash) character it is treated as a fragment and 394*6236dae4SAndroid Build Coastguard Workerit gets cut off by libcurl if provided literally. You have to escape it by 395*6236dae4SAndroid Build Coastguard Workerproviding it as backslash and its ASCII value in hexadecimal: `\23`. 396