Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Scheme

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

parse_uri

absolute-URI

required

parse_absolute_uri

URI-reference

optional

parse_uri_reference

relative-ref

none

parse_relative_ref

origin-form

none

parse_origin_form


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");
Scheme Registry

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.


PrevUpHomeNext