Initial release: April 2004
Kris
- class Uri : 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 port getPort ¶
-
- static this() [shared] ¶
-
Initialize the Uri character maps and so on
- this() ¶
-
- 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.
- int defaultPort(const(char)[] scheme) [override, final, const] ¶
-
Return the default port for the given scheme. InvalidPort
is returned if the scheme is unknown, or does not accept
a port.
- const(char)[] scheme() [@property, override, final, const] ¶
-
Return the parsed scheme, or null if the scheme was not
specified
- const(char)[] host() [@property, override, final, const] ¶
-
Return the parsed host, or null if the host was not
specified
- int port() [@property, override, final, const] ¶
-
Return the parsed port number, or InvalidPort if the port
was not provided.
- int validPort() [override, final, const] ¶
-
Return a valid port number by performing a lookup on the
known schemes if the port was not explicitly specified.
- const(char)[] userinfo() [@property, override, final, const] ¶
-
Return the parsed userinfo, or null if userinfo was not
provided.
- const(char)[] path() [@property, override, final, const] ¶
-
Return the parsed path, or null if the path was not
provided.
- const(char)[] query() [@property, override, final, const] ¶
-
Return the parsed query, or null if a query was not
provided.
- const(char)[] fragment() [@property, override, final, const] ¶
-
Return the parsed fragment, or null if a fragment was not
provided.
- bool isGeneric() [@property, override, final, const] ¶
-
Return whether or not the Uri scheme is considered generic.
- size_t produce(Consumer consume) [final, const] ¶
-
Emit the content of this Uri via the provided Consumer. The
output is constructed per RFC 2396.
- string toString() [override, final] ¶
-
Emit the content of this Uri via the provided Consumer. The
output is constructed per RFC 2396.
- size_t encode(Consumer consume, const(char)[] s, int flags) [static] ¶
-
Encode uri characters into a Consumer, such that
reserved chars are converted into their %hex version.
- char[] encode(const(char)[] text, int flags) [static] ¶
-
Encode uri characters into a string, such that reserved
chars are converted into their %hex version.
Returns a dup'd string
- char[] decode(const(char)[] s) [final] ¶
-
Decode a duplicated string with potential %hex values in it
- Uri parse(const(char)[] uri, bool relative = false) [final] ¶
-
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.
- void reset() [final] ¶
-
Clear everything to null.
- Uri relParse(const(char)[] uri) [final] ¶
-
Parse the given uri, with support for relative URLs
- Uri scheme(const(char)[] scheme) [@property, final] ¶
-
- Uri host(const(char)[] host) [@property, final] ¶
-
- Uri port(int port) [@property, final] ¶
-
- Uri userinfo(const(char)[] userinfo) [@property, final] ¶
-
- Uri query(const(char)[] query) [@property, final] ¶
-
- const(char)[] extendQuery(const(char)[] tail) [final] ¶
-
- Uri path(const(char)[] path) [@property, final] ¶
-
- Uri fragment(const(char)[] fragment) [@property, final] ¶
-