:relfileprefix: ../../../
[#boost-urls-url_base-set_encoded_authority]

= xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/url_base.adoc[pass:[url_base]]::set_encoded_authority


Set the authority


== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_base.hpp#L363[boost/url/url_base.hpp,window=blank_]>`

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

== Description


This function sets the authority
to the specified string.
The string may contain percent-escapes.

=== Example
[,cpp]
----
assert( url().set_encoded_authority( "My%20Computer" ).has_authority() );
----

=== Exception Safety

Strong guarantee.
Calls to allocate may throw.
Exceptions thrown on invalid input.

=== BNF
[,cpp]
----
authority     = [ userinfo "@" ] host [ ":" port ]

userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
host          = IP-literal / IPv4address / reg-name
port          = *DIGIT
----

=== Specification

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



== Exceptions

|===
| Name | Thrown on

| `system_eror`
| 
The string contains an invalid percent-encoding.

|===



== Parameters

|===
| Name | Description 

| *s*
| 
The authority string to set.

|===




== See Also


xref:boost/urls/url_base/remove_authority.adoc[remove_authority]
.



