[ CCode ( has_construct_function = false ) ]
public URI (string? uri_string)

Parses an absolute URI.

You can also pass null for uri_string if you want to get back an "empty" URI that you can fill in by hand. (You will need to call at least set_scheme and set_path, since those fields are required.)

Example: URIs:

public static int main (string[] args) {
Soup.URI uri = new Soup.URI ("http://username:password@localhost:8088/foo/bar.html?foo=f&bar=b#frag");

// Output: ``Fragment: frag``
unowned string fragment = uri.get_fragment ();
print ("Fragment: %s\n", fragment);

// Output: ``Host: localhost``
unowned string host = uri.get_host ();
print ("Host: %s\n", host);

// Output: ``Password: password``
unowned string passwd = uri.get_password ();
print ("Password: %s\n", passwd);

// Output: ``Path: /foo/bar.html``
unowned string path = uri.get_path ();
print ("Path: %s\n", path);

// Output: ``Port: 8088``
uint port = uri.get_port ();
print ("Port: %u\n", port);

// Output: ``Query: foo=f&bar=b``
unowned string query = uri.get_query ();
print ("Query: %s\n", query);

// Output: ``Scheme: http``
unowned string scheme = uri.get_scheme ();
print ("Scheme: %s\n", scheme);

// Output: ``User: username``
unowned string user = uri.get_user ();
print ("User: %s\n", user);

return 0;

valac --pkg libsoup-2.4 uri.vala





a URI, or null if the given string was found to be invalid.