Home | Libraries | People | FAQ | More |
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:
http://www.example.com/images/cat-photo.gif
The scheme is sometimes omitted from the URL when it is implied by the surrounding
context. The text john.doe@example.com
is widely understood
to be an email address, but with the explicit mailto
URI scheme it becomes mailto:john.doe@example.com
.
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
Name |
Scheme |
Function |
---|---|---|
URI |
required |
|
absolute-URI |
required |
|
URI-reference |
optional |
|
relative-ref |
none |
|
origin-form |
none |
The origin-form grammar is used in the HTTP request-line, where the scheme is omitted and the path must be absolute (start with '/'): For example, here is a GET request-line:
GET /pub/WWW/TheProject.html HTTP/1.1
The scheme is implied as http or https depending on the type of connection.
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.