URL syntax

The syntax for the rest of the URL varies depending on the scheme selected. URL schemes that involve the direct use of an IP-based protocol for a specified host on the Internet use the following common syntax for scheme-specific data:


//user:password@host:port/url_path

Some or all parts of user:password@, :password, :port, and /url_path can be excluded. The scheme-specific data start with a double slash (//) to indicate that it complies with the common Internet scheme syntax. The user:password component conforms to the following rules:

user
An optional user name. Some schemes allow the specification of a user name.
password
An optional password. When present, it follows the user name and is separated by a colon. The user name and password are followed by an at sign (@). Within the user and password field, any :, @, or / characters must be encoded. See "URL Encoding" .

The url_path of an FTP URL has the following syntax:


cwd1/cwd2/.../cwdN/name;type= xfer_type

where cwd1 through cwdN and name are possibly encoded strings and xfer_type is one of the characters a, i, or d. The part ;type= xfer_type be omitted. The cwdx and name parts be empty. The whole url_path be omitted, including the /, delimiting it from the prefix containing user, password, host, and port.

The url_path is interpreted as a series of FTP commands as follows:

  • Each cwd element is to be sequentially supplied as the argument to a CWD, change working directory, command.
  • If the typecode is "d", perform a NLST, name list, command with name as the argument and interpret the results as a file directory listing.
  • Otherwise, perform a TYPE command with xfer_type as the argument and then access the file named name. For example, using the RETR command.

    The xfer_type argument has been extended beyond what is supported by the RFC, specifically the D1, D2, D3, and D4 sections. Also, host:port be excluded, although it is rarely useful to do so; host defaults to localhost.