Libzypp/API/Url
The documentation of the zypp::Url class API can be found in doxygen reference installed in /usr/share/doc/packages/libzypp.
This page provides further notes and examples about the implementation and scheme specific restrictions.
İçindekiler
All URLs require a scheme.
All constructors or operators using a escapedUrl string parameter throws, if the scheme is empty or invalid, for example:
Url url1; // OK, empty instance. url1.isValid() returns false. Url url2(url1); // stll OK and empty instance, url2.isValid() returns false Url url3(url1.asString()); // throws, since string does not contain a scheme Url url4(""); // throws, the string does not contain a scheme. Url url5 = ""; // throws, the string does not contain a scheme.
The Url scheme repository.
The Url class contains a repository allowing to configure its behaviour
depending on the scheme providing a preconfigured instance of the
zypp::url::UrlBase class or a derived one.
By default, following (MediaManager specific) schemes are registered:
hd, cd, dvd, dir, iso:
- requires a non-empty path name component
- disallows non-empty authority (user, pass, host, port)
- toString() explicitely shows empty authority (e.g. "cd:///")
Examples:
Url url1("cd:/"); // OK, no authority Url url2("cd:///"); // OK, empty authority Url url3(url1); // OK, should qualify it to "cd:///". Url url3("cd:"); // throws - path name missed Url url4("cd://localhost/"); // throws - hostname not allowed
file:
- requires a non-empty path name component
- allows a host (RFC1738), but disallows user, pass, port
- if no host (authority) given, allows relative path names
- toString() does not show empty authority (e.g. just "file:/foo")
Examples:
Url url1("file:/foo"); // OK, no authority Url url2("file:./bar"); // OK, no authority, relative path Url url3("file:///foo"); // OK, empty authority Url url4("file://localhost/"); // OK, host allowed
mailto, urn:
- requires a non-empty path name component
- disallows non-empty authority (user, pass, host, port)
- toString() hides the empty authority (no "//" after the "scheme:")
Examples:
Url url1("urn:foo:bar"); // OK, no authority Url url2("mailto:foo@bar"); // OK, empty authority Url url3("mailto:"); // throws - path name missed Url url4("urn://localhost/"); // throws - hostname not allowed
nfs, smb, cifs, ftp, http, https:
- requires a non-empty host name component (in the authority)
Examples:
Url url1("ftp://localhost"); // OK, host provided, empty path Url url2("http:/foo/bar"); // throws - hostname missed
ldap, ldaps:
- Disallows username and password in the authority.
- Disallows path parameters and fragment components.
- Changes query string parsing parameters.
- Overloads query parameter map methods to implement simple support
for parsing of the query string into a map using "attrs", "scope",
"filter", "exts" as keys.
Examples:
Url url("ldap://ldap.example.net/dc=example,dc=net?cn,sn?sub?(cn=*)"); url.getQueryParam("scope"); // returns "sub" url.getQueryParam("attrs"); // returns "cn,sn" url.getQueryParam("filter"); // returns "(cn=*)"
Verifying with isValid() method.
In some cases it is not possible to detect invalid url and throw imediately. This
happens for example, if the Url is constructed from empty instance.
Because of this, the isValid() function implements following checks:
- whether the scheme is not empty (the Url url; case)
- whether a host is there if required by the scheme
- whether a path name is there if required by the scheme
- whether the path begins with a "/" in case, that the host is and the path name are not empty.
Last edit in Trac '03/23/06 11:23:11' by 'mt'
Last edit in Trac '03/23/06 11:23:11' by 'mt'
Last edit in Trac '03/23/06 11:23:11' by 'mt'
Last edit in Trac '03/23/06 11:23:11' by 'mt'
Last edit in Trac '03/23/06 11:23:11' by 'mt'