tango.net.Uri

License:
BSD style:

Version:
Initial release: April 2004

author:
Kris

class Uri: tango.net.model.UriView.UriView;
Implements an RFC 2396 compliant URI specification. See this page for more information.

The implementation fails the spec on two counts: it doesn't insist on a scheme being present in the Uri, and it doesn't implement the "Relative References" support noted in section 5.2. The latter can be found in tango.util.PathUtil instead.

Note that IRI support can be implied by assuming each of userinfo, path, query, and fragment are UTF-8 encoded (see this page for further details).

alias getPort;
old method names

this();
Create an empty Uri

this(const(char)[] uri);
Construct a Uri from the provided character string

this(const(char)[] scheme, const(char)[] host, const(char)[] path, const(char)[] query = null);
Construct a Uri from the given components. The query is optional.

this(UriView other);
Clone another Uri. This can be used to make a mutable Uri from an immutable UriView.

const final const int defaultPort(const(char)[] scheme);
Return the default port for the given scheme. InvalidPort is returned if the scheme is unknown, or does not accept a port.

const final const @property const(char)[] scheme();
Return the parsed scheme, or null if the scheme was not specified

const final const @property const(char)[] host();
Return the parsed host, or null if the host was not specified

const final const @property int port();
Return the parsed port number, or InvalidPort if the port was not provided.

const final const int validPort();
Return a valid port number by performing a lookup on the known schemes if the port was not explicitly specified.

const final const @property const(char)[] userinfo();
Return the parsed userinfo, or null if userinfo was not provided.

const final const @property const(char)[] path();
Return the parsed path, or null if the path was not provided.

const final const @property const(char)[] query();
Return the parsed query, or null if a query was not provided.

const final const @property const(char)[] fragment();
Return the parsed fragment, or null if a fragment was not provided.

const final const @property bool isGeneric();
Return whether or not the Uri scheme is considered generic.

const final const size_t produce(Consumer consume);
Emit the content of this Uri via the provided Consumer. The output is constructed per RFC 2396.

final string toString();
Emit the content of this Uri via the provided Consumer. The output is constructed per RFC 2396.

static size_t encode(Consumer consume, const(char)[] s, int flags);
Encode uri characters into a Consumer, such that reserved chars are converted into their %hex version.

static char[] encode(const(char)[] text, int flags);
Encode uri characters into a string, such that reserved chars are converted into their %hex version.

Returns a dup'd string

final char[] decode(const(char)[] s);
Decode a duplicated string with potential %hex values in it

final Uri parse(const(char)[] uri, bool relative = false);
Parsing is performed according to RFC 2396

                  ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
                   12            3  4          5       6  7        8 9


2 isolates scheme 4 isolates authority 5 isolates path 7 isolates query 9 isolates fragment


This was originally a state-machine; it turned out to be a lot faster (~40%) when unwound like this instead.

final void reset();
Clear everything to null.

final Uri relParse(const(char)[] uri);
Parse the given uri, with support for relative URLs

final @property Uri scheme(const(char)[] scheme);
Set the Uri scheme

final @property Uri host(const(char)[] host);
Set the Uri host

final @property Uri port(int port);
Set the Uri port

final @property Uri userinfo(const(char)[] userinfo);
Set the Uri userinfo

final @property Uri query(const(char)[] query);
Set the Uri query

final const(char)[] extendQuery(const(char)[] tail);
Extend the Uri query

final @property Uri path(const(char)[] path);
Set the Uri path

final @property Uri fragment(const(char)[] fragment);
Set the Uri fragment

T[] toLastSlash(T)(T[] path);



Page generated by Ddoc. Copyright (c) 2004 Kris Bell. All rights reserved