Uri

Implements an RFC 2396 compliant URI specification. See <A HREF="http://ftp.ics.uci.edu/pub/ietf/uri/rfc2396.txt">this page</A> 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 <A HREF="http://www.w3.org/2001/Talks/0912-IUC-IRI/paper.html"> this page</A> for further details).

class Uri : UriView {}

Constructors

this
this()

Create an empty Uri

this
this(const(char)[] uri)

Construct a Uri from the provided character string

this
this(const(char)[] scheme, const(char)[] host, const(char)[] path, const(char)[] query)

Construct a Uri from the given components. The query is optional.

this
this(UriView other)

Clone another Uri. This can be used to make a mutable Uri from an immutable UriView.

Members

Aliases

getDefaultPort
alias getDefaultPort = defaultPort
Undocumented in source.
getFragment
alias getFragment = fragment
Undocumented in source.
getHost
alias getHost = host
Undocumented in source.
getPath
alias getPath = path
Undocumented in source.
getPort
alias getPort = port

old method names

getQuery
alias getQuery = query
Undocumented in source.
getScheme
alias getScheme = scheme
Undocumented in source.
getUserInfo
alias getUserInfo = userinfo
Undocumented in source.
getValidPort
alias getValidPort = validPort
Undocumented in source.
setFragment
alias setFragment = fragment
Undocumented in source.
setHost
alias setHost = host
Undocumented in source.
setPath
alias setPath = path
Undocumented in source.
setPort
alias setPort = port
Undocumented in source.
setQuery
alias setQuery = query
Undocumented in source.
setScheme
alias setScheme = scheme
Undocumented in source.
setUserInfo
alias setUserInfo = userinfo
Undocumented in source.

Enums

ExcScheme
anonymousenum ExcScheme
Undocumented in source.
InvalidPort
anonymousenum InvalidPort
Undocumented in source.

Functions

decode
char[] decode(const(char)[] s)

Decode a duplicated string with potential %hex values in it

defaultPort
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.

extendQuery
const(char)[] extendQuery(const(char)[] tail)

Extend the Uri query

parse
Uri parse(const(char)[] uri, bool relative)

Parsing is performed according to RFC 2396

produce
size_t produce(Consumer consume)

Emit the content of this Uri via the provided Consumer. The output is constructed per RFC 2396.

relParse
Uri relParse(const(char)[] uri)

Parse the given uri, with support for relative URLs

reset
void reset()

Clear everything to null.

toString
string toString()

Emit the content of this Uri via the provided Consumer. The output is constructed per RFC 2396.

validPort
int validPort()

Return a valid port number by performing a lookup on the known schemes if the port was not explicitly specified.

Properties

fragment
const(char)[] fragment [@property getter]

Return the parsed fragment, or null if a fragment was not provided.

fragment
const(char)[] fragment [@property setter]

Set the Uri fragment

host
const(char)[] host [@property getter]

Return the parsed host, or null if the host was not specified

host
const(char)[] host [@property setter]

Set the Uri host

isGeneric
bool isGeneric [@property getter]

Return whether or not the Uri scheme is considered generic.

path
const(char)[] path [@property getter]

Return the parsed path, or null if the path was not provided.

path
const(char)[] path [@property setter]

Set the Uri path

port
int port [@property getter]

Return the parsed port number, or InvalidPort if the port was not provided.

port
int port [@property setter]

Set the Uri port

query
const(char)[] query [@property getter]

Return the parsed query, or null if a query was not provided.

query
const(char)[] query [@property setter]

Set the Uri query

scheme
const(char)[] scheme [@property getter]

Return the parsed scheme, or null if the scheme was not specified

scheme
const(char)[] scheme [@property setter]

Set the Uri scheme

userinfo
const(char)[] userinfo [@property getter]

Return the parsed userinfo, or null if userinfo was not provided.

userinfo
const(char)[] userinfo [@property setter]

Set the Uri userinfo

Static functions

encode
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.

encode
char[] encode(const(char)[] text, int flags)

Encode uri characters into a string, such that reserved chars are converted into their %hex version.

Inherited Members

From UriView

getPort
alias getPort = port
Undocumented in source.
getDefaultPort
alias getDefaultPort = defaultPort
Undocumented in source.
getScheme
alias getScheme = scheme
Undocumented in source.
getHost
alias getHost = host
Undocumented in source.
getValidPort
alias getValidPort = validPort
Undocumented in source.
getUserInfo
alias getUserInfo = userinfo
Undocumented in source.
getPath
alias getPath = path
Undocumented in source.
getQuery
alias getQuery = query
Undocumented in source.
getFragment
alias getFragment = fragment
Undocumented in source.
setPort
alias setPort = port
Undocumented in source.
setScheme
alias setScheme = scheme
Undocumented in source.
setHost
alias setHost = host
Undocumented in source.
setUserInfo
alias setUserInfo = userinfo
Undocumented in source.
setQuery
alias setQuery = query
Undocumented in source.
setPath
alias setPath = path
Undocumented in source.
setFragment
alias setFragment = fragment
Undocumented in source.
InvalidPort
anonymousenum InvalidPort
Undocumented in source.
defaultPort
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.

scheme
const(char)[] scheme()

Return the parsed scheme, or null if the scheme was not specified

host
const(char)[] host()

Return the parsed host, or null if the host was not specified

port
int port()

Return the parsed port number, or InvalidPort if the port was not provided.

validPort
int validPort()

Return a valid port number by performing a lookup on the known schemes if the port was not explicitly specified.

userinfo
const(char)[] userinfo()

Return the parsed userinfo, or null if userinfo was not provided.

path
const(char)[] path()

Return the parsed path, or null if the path was not provided.

query
const(char)[] query()

Return the parsed query, or null if a query was not provided.

fragment
const(char)[] fragment()

Return the parsed fragment, or null if a fragment was not provided.

isGeneric
bool isGeneric()

Return whether or not the UriView scheme is considered generic.

Meta