# Standard network working group reference

Uri

The `Uri` class is a base object used to parse or build a uniform resource identifier as defined by RFC 3986. The URI can be built by specifying each component or by parsing a string. When a string is given in the constructor, the class parses the string and extract all components. The uri components are the scheme, the authority, the path, the query and the fragment. The class also takes care of the character escaping.

uri-p
Object
Uri
none

The `Uri` constructor creates an empty uri object.

Uri
String

The `Uri` constructor create a uri object by value. The string argument is the uri to parse at the object construction.

Uri
String String Integer

The `Uri` constructor create a uri object by scheme host and port. The first argument is the uri scheme. The second argument is the uri host name. The third argument is the uri port. The uri base name can be reconstructed from this information.

parse
none
String

The `parse` method reset the uri object, parse the string argument and fill the uri object with the result.

get-scheme
String
none

The `get-scheme` method returns the scheme of the parsed uri object.

get-authority
String
none

The `get-authority` method returns the authority part of the parsed uri.

get-path
String
none

The `get-path` method returns the path of the parsed uri.

get-path-target
String
none

The `get-path-target` method returns the path target of the parsed uri. The path target is the last element of the uri path.

get-query
String
none

The `get-query` method returns the complete query string of the parsed uri. Note that characters are not escaped when getting the string.

get-fragment
String
none

The `get-fragment` method returns the complete query string of the parsed uri.

get-base
String
none

The `get-base` method returns the combined uri scheme and authority.

get-rname
String
none

The `get-rname` method returns the reference uri name with the combined uri scheme, authority and path all percent encoded.

get-hname
String
none

The `get-hname` method returns the combined uri scheme, authority and path.

get-aname
String
none

The `get-aname` method returns the almost combined uri name with the scheme, authority, path and query.

add-path
Uri
String

The `add-path` method adds a path to the calling uri and returns a new uri with the new path added to the old one.

get-href
Uri
String

The `get-href` method returns a new uri by eventually combining the string argument. If the string argument correspond to an uri, the corresponding uri is built. Otherwise, the string argument is considered as a path to be added to the current uri in order to build a new uri.

get-system-path
String
none

The `get-system-path` method returns the system path representation of the uri path. This function works only if the scheme if a file scheme.

get-path-encoded
String
none

The `get-path-encoded` method returns the uri in the encoded form. Normally the `get-path` removes the percent-encoded characters which might not be appropriate with some protocol such like the http protocol. The `get-path-encoded` returns the original path. Note that getting the path with `getpath` and doing a percent coding might result in a different result since the internal representation uses normalized string.

get-host
String
none

The `get-host` method returns the authority or path host name if any can be found with respect to the scheme. With a ftp, http or https scheme, the host is extracted from the authority. With a mailto scheme, the host is extracted from the path.

get-port
Integer
none

The `get-port` method returns the authority port if any can be found with respect to the scheme.

UriQuery

The `UriQuery` class is a simple class that parses a uri query string and build property list. during the parsing process, a special transliteration process is done as specified by RFC 3986. This class is primarily used with cgi scripts. Note that the string to parse is exactly the one produced by the `get-query` method of the `Uri` class.

uri-query-p
Plist
UriQuery
none

The `UriQuery` constructor creates an empty uri query object.

UriQuery
String

The `UriQuery` constructor create a uri object by value. The string argument is the uri query string to parse at the object construction. The query string is the one obtained from the `get-query` method of the `Uri` class.

parse
none
String

The `parse` method reset the uri query object, parses the string argument and fill the property list object with the result.

get-query
String
none

The `get-query` method returns the original query string.

mime-extension-p
Boolean
String

The `mime-extension-p` predicates returns true if a media type extension - mime extension - is defined. Most of the time, media type extension can be seen as a file extension.

mime-value-p
Boolean
String

The `mime-value-p` predicates returns true if a media type - mime value - is defined.

extension-to-mime
String
String [Boolean]

The `extension-to-mime` function converts a media type extension into a media type. In the first form, without a second argument, if the media type extension does not exist, an exception is raised. In the second form, with the second argument set to true, if the media type extension does not exist, the default media type is returned. If the flag is set to false, an exception is raised like the first form.

normalize-uri-name
String
String

The `normalize-uri-name` function normalizes the string argument by adding a uri scheme if missing in the original string. If the function detects that the name starts with a host name, the "http" scheme is added. If the function detects that the string starts with a path, the "file" scheme is added. otherwise, the name argument is left untouched.

system-uri-name
String
String

The `system-uri-name` function normalizes the string argument by prioritizing the system name. The function attempts to find a file that match the string argument and eventually build a uri file scheme. If the file is not fond, the normalization process occurs with the `normalize-uri-name` function.