Skip to content

Commit 8e09ae6

Browse files
committed
fixed 2 unit tests
uri_builder_tests:to_string_invalid_uri uri_builder_tests:append_query_locale
1 parent 5c95411 commit 8e09ae6

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

Release/include/cpprest/base_uri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ namespace web {
227227
/// Creates a URI from the given URI components.
228228
/// </summary>
229229
/// <param name="components">A URI components object to create the URI instance.</param>
230-
_ASYNCRTIMP uri(const details::uri_components &components) : m_components(components) { m_uri = m_components.join(); }
230+
_ASYNCRTIMP uri(const details::uri_components &components);
231231

232232
/// <summary>
233233
/// Creates a URI from the given encoded string. This will throw an exception if the string

Release/include/cpprest/http_headers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class http_headers
159159
{
160160
if (has(name))
161161
{
162-
m_headers[name] = m_headers[name].append(_XPLATSTR(", ")).append(utility::conversions::print_string(value));
162+
m_headers[name].append(_XPLATSTR(", ")).append(utility::conversions::print_string(value));
163163
}
164164
else
165165
{

Release/include/cpprest/uri_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ namespace web
238238
uri_builder &append_query(const utility::string_t &name, const T &value, bool do_encoding = true)
239239
{
240240
auto encodedName = name;
241-
auto encodedValue = ::utility::conversions::print_string(value);
241+
auto encodedValue = ::utility::conversions::print_string(value, std::locale::classic());
242242

243243
if (do_encoding)
244244
{

Release/src/uri/uri.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ utility::string_t uri_components::join()
7373

7474
if (m_port > 0)
7575
{
76-
ret.append({ _XPLATSTR(':') }).append(utility::conversions::print_string(m_port));
76+
ret.append({ _XPLATSTR(':') }).append(utility::conversions::print_string(m_port, std::locale::classic()));
7777
}
7878
}
7979

@@ -104,6 +104,15 @@ utility::string_t uri_components::join()
104104

105105
using namespace details;
106106

107+
uri::uri(const details::uri_components &components) : m_components(components)
108+
{
109+
m_uri = m_components.join();
110+
if (!details::uri_parser::validate(m_uri))
111+
{
112+
throw uri_exception("provided uri is invalid: " + utility::conversions::to_utf8string(m_uri));
113+
}
114+
}
115+
107116
uri::uri(const utility::string_t &uri_string)
108117
{
109118
if (!details::uri_parser::parse(uri_string, m_components))

0 commit comments

Comments
 (0)