:relfileprefix: ../../../
[#3EDE2270946027150B8108DB5D5EB2CC18A0365F]

= Function url_base::set_host_name

pass:v,q[Set the host to a name]


== Synopsis

Declared in header `</boost/url/url_base.hpp#L1425[boost/url/url_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/url_base.adoc[url_base]&
set_host_name(string_view s);
----

== Description

pass:v,q[The host is set to the specified string,] pass:v,q[which may be empty.]
pass:v,q[Reserved characters in the string are]
pass:v,q[percent-escaped in the result.]
pass:v,q[The host type is]
xref:boost/urls/host_type/name.adoc[host_type::name.]

=== Example
[,cpp]
----
assert( url( "http://www.example.com/index.htm").set_host_name( "localhost" ).host_address() == "localhost" );
----

=== Postconditions
[,cpp]
----
this->has_authority() == true && this->host_ipv6_address() == addr && this->host_type() == host_type::name
----

=== Exception Safety
pass:v,q[Strong guarantee.]
pass:v,q[Calls to allocate may throw.]

=== BNF
[,cpp]
----
reg-name    = *( unreserved / pct-encoded / "-" / ".")
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[            3.2.2. Host (rfc3986)]



== Return Value

* `` 


== Parameters

|===
| Name | Type 

| *s*
| `string_view`

|===



