:relfileprefix: ../../../
[#boost-urls-url-set_scheme]

= xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/url.adoc[pass:[url]]::set_scheme


Set the scheme


== Synopsis

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

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

== Description


The scheme is set to the specified
string, which must contain a valid
scheme without any trailing colon
(':').
Note that schemes are case-insensitive,
and the canonical form is lowercased.

=== Example
[,cpp]
----
assert( url( "http://www.example.com" ).set_scheme( "https" ).scheme_id() == scheme::https );
----

=== Complexity

Linear in `this-&gt;size() + s.size()`.

=== Exception Safety

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

=== BNF
[,cpp]
----
scheme        = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
----

=== Specification

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



== Exceptions

|===
| Name | Thrown on

| `system_error`
| 
`s` contains an invalid scheme.

|===



== Parameters

|===
| Name | Description 

| *s*
| 
The scheme to set.

|===




== See Also


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



