Every URL has a scheme: a case-insensitive word that precisely specifies both the meaning and the syntax of the remainder of the URL. Almost everyone has seen examples of the http URI scheme, used to identify resources on the World Wide Web:
The scheme is sometimes omitted from the URL when it is implied by the surrounding
context. The text
firstname.lastname@example.org is widely understood
to be an email address, but with the explicit mailto
URI scheme it becomes
When a URL lacks a scheme, it is the caller's responsibility to validate
the semantic contents according to the surrounding context. This table shows
the top level grammars, their treatment of the scheme, and the library function
used to interpret strings using that grammar:
Table 1.3. Grammar
GET /pub/WWW/TheProject.html HTTP/1.1
One of the conventions of the HTTP scheme is that when the port 80 is implicitly assumed when it is not provided. Such conventions are not part of the URL protocol.
The scheme is the top-level component defining the semantics of the URL. It usually represents a protocol, such as HTTP or FTP. In these protocols, the path describes a resource and the host describes how to access it.
url_view u( "ftp://ftp.is.co.za/rfc/rfc1808.txt" ); assert(u.scheme() == "ftp"); assert(u.host() == "ftp.is.co.za"); assert(u.path() == "/rfc/rfc1808.txt");
To facilitate interoperability standards,the Internet Assigned Numbers Authority (IANA) maintains a registry of published URI schemes, in the official URI Scheme Registry. For more information about custom schemes including their grammar and semantics, please consult the registry.