Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
static_url::resolve

(Inherited from url_base)

Resolve a URL reference against this base URL.

Synopsis
result< void >
resolve(
    url_view_base const& ref);
Description

This function attempts to resolve a URL reference ref against this base URL in a manner similar to that of a web browser resolving an anchor tag. This URL must satisfy the URI grammar. In other words, it must contain a scheme. Relative references are only usable when in the context of a base absolute URI. This process of resolving a relative reference within the context of a base URI is defined in detail in rfc3986 (see below). The resolution process works as if the relative reference is appended to the base URI and the result is normalized. Given the input base URL, this function resolves the relative reference as if performing the following steps:

This function places the result of the resolution into this URL in place. If an error occurs, the contents of this URL are unspecified and a result with an error_code is returned.

Example
url base1( "/one/two/three" );
base1.resolve("four");
assert( base1.buffer() == "/one/two/four" );

url base2( "http://example.com/" )
base2.resolve("/one");
assert( base2.buffer() == "http://example.com/one" );

url base3( "http://example.com/one" );
base3.resolve("/two");
assert( base3.buffer() == "http://example.com/two" );

url base4( "http://a/b/c/d;p?q" );
base4.resolve("g#s");
assert( base4.buffer() == "http://a/b/c/g#s" );
BNF
absolute-URI  = scheme ":" hier-part [ "?" query ]
Exception Safety

Basic guarantee. Calls to allocate may throw.

Return Value

An empty result upon success, otherwise an error code if !base.has_scheme().

Parameters

Name

Description

ref

The URL reference to resolve.

Specification

5. Reference Resolution (rfc3986)

See Also

url, url_view.


PrevUpHomeNext