32 #include "cpprest/base_uri.h"
33 #include "cpprest/details/uri_parser.h"
59 const utility::string_t &
scheme()
const {
return m_uri.m_scheme; }
65 const utility::string_t &
user_info()
const {
return m_uri.m_user_info; }
71 const utility::string_t &
host()
const {
return m_uri.m_host; }
77 int port()
const {
return m_uri.m_port; }
83 const utility::string_t &
path()
const {
return m_uri.m_path; }
89 const utility::string_t &
query()
const {
return m_uri.m_query; }
95 const utility::string_t &
fragment()
const {
return m_uri.m_fragment; }
151 utility::istringstream_t portStream(port);
153 portStream >> port_tmp;
154 if(portStream.fail() || portStream.bad())
156 throw std::invalid_argument(
"invalid port argument, must be non empty string containing integer value");
158 m_uri.m_port = port_tmp;
240 auto encodedName = name;
241 auto encodedValue = ::utility::conversions::print_string(value, std::locale::classic());
245 auto encodingCheck = [](
int ch)
258 return !::web::details::uri_parser::is_query_character(ch);
261 encodedName = uri::encode_impl(encodedName, encodingCheck);
262 encodedValue = uri::encode_impl(encodedValue, encodingCheck);
265 auto encodedQuery = encodedName;
266 encodedQuery.append(_XPLATSTR(
"="));
267 encodedQuery.append(encodedValue);
276 _ASYNCRTIMP utility::string_t
to_string();
uri_builder & set_port(const utility::string_t &port)
Set the port component of the URI.
Definition: uri_builder.h:149
const utility::string_t & host() const
Get the host component of the URI as an encoded string.
Definition: uri_builder.h:71
const utility::string_t & user_info() const
Get the user information component of the URI as an encoded string.
Definition: uri_builder.h:65
A flexible, protocol independent URI implementation.
Definition: base_uri.h:151
uri_builder & set_host(const utility::string_t &host, bool do_encoding=false)
Set the host component of the URI.
Definition: uri_builder.h:126
void clear()
Clears all components of the underlying URI in this uri_builder.
Definition: uri_builder.h:202
The web namespace contains functionality common to multiple protocols like HTTP and WebSockets...
Definition: base_uri.h:37
int port() const
Get the port component of the URI. Returns -1 if no port is specified.
Definition: uri_builder.h:77
uri_builder & append_query(const utility::string_t &name, const T &value, bool do_encoding=true)
Appends another query to the query of this uri_builder, encoding it first. This overload is useful wh...
Definition: uri_builder.h:238
uri_builder & set_scheme(const utility::string_t &scheme)
Set the scheme of the URI.
Definition: uri_builder.h:102
_ASYNCRTIMP uri_builder & append(const uri &relative_uri)
Appends an relative uri (Path, Query and fragment) at the end of the current uri. ...
static _ASYNCRTIMP utility::string_t __cdecl encode_uri(const utility::string_t &raw, uri::components::component=components::full_uri)
Encodes a URI component according to RFC 3986. Note if a full URI is specified instead of an individu...
uri_builder & set_port(int port)
Set the port component of the URI.
Definition: uri_builder.h:137
_ASYNCRTIMP utility::string_t to_string()
Combine and validate the URI components into a encoded string. An exception will be thrown if the URI...
const utility::string_t & fragment() const
Get the fragment component of the URI as an encoded string.
Definition: uri_builder.h:95
uri_builder & set_path(const utility::string_t &path, bool do_encoding=false)
Set the path component of the URI.
Definition: uri_builder.h:168
const utility::string_t & path() const
Get the path component of the URI as an encoded string.
Definition: uri_builder.h:83
_ASYNCRTIMP bool is_valid()
Validate the generated URI from all existing components of this uri_builder.
uri_builder()
Creates a builder with an initially empty URI.
Definition: uri_builder.h:47
_ASYNCRTIMP uri to_uri()
Combine and validate the URI components into a URI class instance. An exception will be thrown if the...
const utility::string_t & scheme() const
Get the scheme component of the URI as an encoded string.
Definition: uri_builder.h:59
uri_builder & set_query(const utility::string_t &query, bool do_encoding=false)
Set the query component of the URI.
Definition: uri_builder.h:181
Definition: base_uri.h:40
const utility::string_t & query() const
Get the query component of the URI as an encoded string.
Definition: uri_builder.h:89
uri_builder & set_fragment(const utility::string_t &fragment, bool do_encoding=false)
Set the fragment component of the URI.
Definition: uri_builder.h:193
Builder for constructing URIs incrementally.
Definition: uri_builder.h:40
_ASYNCRTIMP uri_builder & append_query(const utility::string_t &query, bool do_encoding=false)
Appends another query to the query of this uri_builder.
_ASYNCRTIMP uri_builder & append_path(const utility::string_t &path, bool do_encoding=false)
Appends another path to the path of this uri_builder.
uri_builder & set_user_info(const utility::string_t &user_info, bool do_encoding=false)
Set the user info component of the URI.
Definition: uri_builder.h:114
uri_builder(const uri &uri_str)
Creates a builder with a existing URI object.
Definition: uri_builder.h:53