set_host


Description:

public void set_host (string? host)

Sets this's host to host.

If host is an IPv6 IP address, it should not include the brackets required by the URI syntax; they will be added automatically when converting this to a string.

http and https URIs should not have a null host.

Example: Set and get the host:

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: ``Host: localhost``
unowned string host = uri.get_host ();
print ("Host: %s\n", host);

// Output: ``URI: http://username@valadoc.org:8088/foo/bar.html?foo=f&bar=b#frag``
uri.set_host ("valadoc.org");
string uri_str = uri.to_string (false);
print ("URI: %s\n", uri_str);

return 0;
}

valac --pkg libsoup-2.4 uri-host.vala

Parameters:

this

a URI

host

the hostname or IP address, or null