diff --git a/Release/include/cpprest/asyncrt_utils.h b/Release/include/cpprest/asyncrt_utils.h
index 21c92de294..23ec9aca02 100644
--- a/Release/include/cpprest/asyncrt_utils.h
+++ b/Release/include/cpprest/asyncrt_utils.h
@@ -68,35 +68,35 @@ namespace conversions
///
/// A two byte character UTF-16 string.
/// A single byte character UTF-8 string.
- _ASYNCRTIMP std::string __cdecl utf16_to_utf8(const utf16string &w);
+ _ASYNCRTIMP utility::string __cdecl utf16_to_utf8(const utf16string &w);
///
/// Converts a UTF-8 string to a UTF-16
///
/// A single byte character UTF-8 string.
/// A two byte character UTF-16 string.
- _ASYNCRTIMP utf16string __cdecl utf8_to_utf16(const std::string &s);
+ _ASYNCRTIMP utf16string __cdecl utf8_to_utf16(const utility::string &s);
///
/// Converts a ASCII (us-ascii) string to a UTF-16 string.
///
/// A single byte character us-ascii string.
/// A two byte character UTF-16 string.
- _ASYNCRTIMP utf16string __cdecl usascii_to_utf16(const std::string &s);
+ _ASYNCRTIMP utf16string __cdecl usascii_to_utf16(const utility::string &s);
///
/// Converts a Latin1 (iso-8859-1) string to a UTF-16 string.
///
/// A single byte character UTF-8 string.
/// A two byte character UTF-16 string.
- _ASYNCRTIMP utf16string __cdecl latin1_to_utf16(const std::string &s);
+ _ASYNCRTIMP utf16string __cdecl latin1_to_utf16(const utility::string &s);
///
/// Converts a Latin1 (iso-8859-1) string to a UTF-8 string.
///
/// A single byte character UTF-8 string.
/// A single byte character UTF-8 string.
- _ASYNCRTIMP utf8string __cdecl latin1_to_utf8(const std::string &s);
+ _ASYNCRTIMP utf8string __cdecl latin1_to_utf8(const utility::string &s);
///
/// Converts to a platform dependent Unicode string type.
@@ -104,9 +104,9 @@ namespace conversions
/// A single byte character UTF-8 string.
/// A platform dependent string type.
#ifdef _UTF16_STRINGS
- _ASYNCRTIMP utility::string_t __cdecl to_string_t(std::string &&s);
+ _ASYNCRTIMP utility::string_t __cdecl to_string_t(utility::string &&s);
#else
- inline utility::string_t&& to_string_t(std::string &&s) { return std::move(s); }
+ inline utility::string_t&& to_string_t(utility::string &&s) { return std::move(s); }
#endif
///
@@ -125,9 +125,9 @@ namespace conversions
/// A single byte character UTF-8 string.
/// A platform dependent string type.
#ifdef _UTF16_STRINGS
- _ASYNCRTIMP utility::string_t __cdecl to_string_t(const std::string &s);
+ _ASYNCRTIMP utility::string_t __cdecl to_string_t(const utility::string &s);
#else
- inline const utility::string_t& to_string_t(const std::string &s) { return s; }
+ inline const utility::string_t& to_string_t(const utility::string &s) { return s; }
#endif
///
@@ -146,7 +146,7 @@ namespace conversions
///
/// A single byte character UTF-8 string.
/// A two byte character UTF-16 string.
- _ASYNCRTIMP utf16string __cdecl to_utf16string(const std::string &value);
+ _ASYNCRTIMP utf16string __cdecl to_utf16string(const utility::string &value);
///
/// Converts to a UTF-16 from string.
@@ -172,26 +172,26 @@ namespace conversions
///
/// A single byte character UTF-8 string.
/// A single byte character UTF-8 string.
- inline std::string&& to_utf8string(std::string&& value) { return std::move(value); }
+ inline utility::string&& to_utf8string(utility::string&& value) { return std::move(value); }
///
/// Converts to a UTF-8 string.
///
/// A single byte character UTF-8 string.
/// A single byte character UTF-8 string.
- inline const std::string& to_utf8string(const std::string& value) { return value; }
+ inline const utility::string& to_utf8string(const utility::string& value) { return value; }
///
/// Converts to a UTF-8 string.
///
/// A two byte character UTF-16 string.
/// A single byte character UTF-8 string.
- _ASYNCRTIMP std::string __cdecl to_utf8string(const utf16string &value);
+ _ASYNCRTIMP utility::string __cdecl to_utf8string(const utf16string &value);
///
/// Encode the given byte array into a base64 string
///
- _ASYNCRTIMP utility::string_t __cdecl to_base64(const std::vector& data);
+ _ASYNCRTIMP utility::string_t __cdecl to_base64(const utility::vector& data);
///
/// Encode the given 8-byte integer into a base64 string
@@ -201,7 +201,7 @@ namespace conversions
///
/// Decode the given base64 string to a byte array
///
- _ASYNCRTIMP std::vector __cdecl from_base64(const utility::string_t& str);
+ _ASYNCRTIMP utility::vector __cdecl from_base64(const utility::string_t& str);
template
CASABLANCA_DEPRECATED("All locale-sensitive APIs will be removed in a future update. Use stringstreams directly if locale support is required.")
@@ -226,28 +226,42 @@ namespace conversions
namespace details
{
-#if defined(__ANDROID__)
template
- inline std::string to_string(const T t)
+ inline utility::string to_string(const T t)
{
- std::ostringstream os;
+#if defined(__ANDROID__)
+ utility::ostringstream os;
os.imbue(std::locale::classic());
os << t;
return os.str();
+#else
+ using std::to_string;
+ return to_string(t).c_str();
+#endif
+ }
+
+#if defined(_WIN32) || defined(_UTF16_STRINGS)
+ template
+ inline utility::wstring to_wstring(const T t) {
+ using std::to_wstring;
+ return to_wstring(t).c_str();
}
#endif
template
inline utility::string_t to_string_t(const T t)
{
-#ifdef _UTF16_STRINGS
+#if defined(_WIN32) || defined(_UTF16_STRINGS)
using std::to_wstring;
- return to_wstring(t);
+ return to_wstring(t).c_str();
+#elif defined(__ANDROID__)
+ utility::ostringstream os;
+ os.imbue(std::locale::classic());
+ os << t;
+ return os.str();
#else
-#if !defined(__ANDROID__)
using std::to_string;
-#endif
- return to_string(t);
+ return to_string(t).c_str();
#endif
}
@@ -343,7 +357,7 @@ namespace details
#endif
private:
#ifdef _WIN32
- std::string m_prevLocale;
+ utility::string m_prevLocale;
int m_prevThreadSetting;
#elif !(defined(ANDROID) || defined(__ANDROID__))
locale_t m_prevLocale;
@@ -397,42 +411,13 @@ namespace details
return (uch <= static_cast('z') && is_alnum(static_cast(uch)));
}
- ///
- /// Simplistic implementation of make_unique. A better implementation would be based on variadic templates
- /// and therefore not be compatible with Dev10.
- ///
- template
- std::unique_ptr<_Type> make_unique() {
- return std::unique_ptr<_Type>(new _Type());
- }
-
- template
- std::unique_ptr<_Type> make_unique(_Arg1&& arg1) {
- return std::unique_ptr<_Type>(new _Type(std::forward<_Arg1>(arg1)));
- }
-
- template
- std::unique_ptr<_Type> make_unique(_Arg1&& arg1, _Arg2&& arg2) {
- return std::unique_ptr<_Type>(new _Type(std::forward<_Arg1>(arg1), std::forward<_Arg2>(arg2)));
- }
-
- template
- std::unique_ptr<_Type> make_unique(_Arg1&& arg1, _Arg2&& arg2, _Arg3&& arg3) {
- return std::unique_ptr<_Type>(new _Type(std::forward<_Arg1>(arg1), std::forward<_Arg2>(arg2), std::forward<_Arg3>(arg3)));
- }
-
- template
- std::unique_ptr<_Type> make_unique(_Arg1&& arg1, _Arg2&& arg2, _Arg3&& arg3, _Arg4&& arg4) {
- return std::unique_ptr<_Type>(new _Type(std::forward<_Arg1>(arg1), std::forward<_Arg2>(arg2), std::forward<_Arg3>(arg3), std::forward<_Arg4>(arg4)));
- }
-
///
/// Cross platform utility function for performing case insensitive string equality comparision.
///
/// First string to compare.
/// Second strong to compare.
/// true if the strings are equivalent, false otherwise
- _ASYNCRTIMP bool __cdecl str_iequal(const std::string &left, const std::string &right) CPPREST_NOEXCEPT;
+ _ASYNCRTIMP bool __cdecl str_iequal(const utility::string &left, const utility::string &right) CPPREST_NOEXCEPT;
///
/// Cross platform utility function for performing case insensitive string equality comparision.
@@ -440,7 +425,7 @@ namespace details
/// First string to compare.
/// Second strong to compare.
/// true if the strings are equivalent, false otherwise
- _ASYNCRTIMP bool __cdecl str_iequal(const std::wstring &left, const std::wstring &right) CPPREST_NOEXCEPT;
+ _ASYNCRTIMP bool __cdecl str_iequal(const utility::wstring &left, const utility::wstring &right) CPPREST_NOEXCEPT;
///
/// Cross platform utility function for performing case insensitive string less-than comparision.
@@ -448,7 +433,7 @@ namespace details
/// First string to compare.
/// Second strong to compare.
/// true if a lowercase view of left is lexicographically less than a lowercase view of right; otherwise, false.
- _ASYNCRTIMP bool __cdecl str_iless(const std::string &left, const std::string &right) CPPREST_NOEXCEPT;
+ _ASYNCRTIMP bool __cdecl str_iless(const utility::string &left, const utility::string &right) CPPREST_NOEXCEPT;
///
/// Cross platform utility function for performing case insensitive string less-than comparision.
@@ -456,19 +441,19 @@ namespace details
/// First string to compare.
/// Second strong to compare.
/// true if a lowercase view of left is lexicographically less than a lowercase view of right; otherwise, false.
- _ASYNCRTIMP bool __cdecl str_iless(const std::wstring &left, const std::wstring &right) CPPREST_NOEXCEPT;
+ _ASYNCRTIMP bool __cdecl str_iless(const utility::wstring &left, const utility::wstring &right) CPPREST_NOEXCEPT;
///
/// Convert a string to lowercase in place.
///
/// The string to convert to lowercase.
- _ASYNCRTIMP void __cdecl inplace_tolower(std::string &target) CPPREST_NOEXCEPT;
+ _ASYNCRTIMP void __cdecl inplace_tolower(utility::string &target) CPPREST_NOEXCEPT;
///
/// Convert a string to lowercase in place.
///
/// The string to convert to lowercase.
- _ASYNCRTIMP void __cdecl inplace_tolower(std::wstring &target) CPPREST_NOEXCEPT;
+ _ASYNCRTIMP void __cdecl inplace_tolower(utility::wstring &target) CPPREST_NOEXCEPT;
#ifdef _WIN32
@@ -528,7 +513,7 @@ inline std::error_code __cdecl create_error_code(unsigned long errorCode)
///
inline utility::string_t __cdecl create_error_message(unsigned long errorCode)
{
- return utility::conversions::to_string_t(create_error_code(errorCode).message());
+ return utility::conversions::to_string_t(create_error_code(errorCode).message().c_str());
}
}
diff --git a/Release/include/cpprest/base_uri.h b/Release/include/cpprest/base_uri.h
index b5fc8fcfd0..bcf3502ad9 100644
--- a/Release/include/cpprest/base_uri.h
+++ b/Release/include/cpprest/base_uri.h
@@ -78,7 +78,7 @@ namespace web {
{
public:
- uri_exception(std::string msg) : m_msg(std::move(msg)) {}
+ uri_exception(utility::string msg) : m_msg(std::move(msg)) {}
~uri_exception() CPPREST_NOEXCEPT {}
@@ -88,7 +88,7 @@ namespace web {
}
private:
- std::string m_msg;
+ utility::string m_msg;
};
///
@@ -167,15 +167,15 @@ namespace web {
/// Splits a path into its hierarchical components.
///
/// The path as a string
- /// A std::vector<utility::string_t> containing the segments in the path.
- _ASYNCRTIMP static std::vector __cdecl split_path(const utility::string_t &path);
+ /// A utility::vector<utility::string_t> containing the segments in the path.
+ _ASYNCRTIMP static utility::vector __cdecl split_path(const utility::string_t &path);
///
/// Splits a query into its key-value components.
///
/// The query string
- /// A std::map<utility::string_t, utility::string_t> containing the key-value components of the query.
- _ASYNCRTIMP static std::map __cdecl split_query(const utility::string_t &query);
+ /// A utility::map<utility::string_t, utility::string_t> containing the key-value components of the query.
+ _ASYNCRTIMP static utility::map __cdecl split_query(const utility::string_t &query);
///
/// Validates a string as a URI.
diff --git a/Release/include/cpprest/containerstream.h b/Release/include/cpprest/containerstream.h
index 63ead19f9b..7050e74013 100644
--- a/Release/include/cpprest/containerstream.h
+++ b/Release/include/cpprest/containerstream.h
@@ -55,6 +55,25 @@ namespace Concurrency { namespace streams {
return m_data;
}
+ ///
+ /// Constructor
+ ///
+ basic_container_buffer(std::ios_base::openmode mode)
+ : streambuf_state_manager(mode),
+ m_current_position(0) {
+ validate_mode(mode);
+ }
+
+ ///
+ /// Constructor
+ ///
+ basic_container_buffer(_CollectionType data, std::ios_base::openmode mode)
+ : streambuf_state_manager(mode),
+ m_data(std::move(data)),
+ m_current_position((mode & std::ios_base::in) ? 0 : m_data.size()) {
+ validate_mode(mode);
+ }
+
///
/// Destructor
///
@@ -363,27 +382,6 @@ namespace Concurrency { namespace streams {
private:
template friend class streams::container_buffer;
- ///
- /// Constructor
- ///
- basic_container_buffer(std::ios_base::openmode mode)
- : streambuf_state_manager(mode),
- m_current_position(0)
- {
- validate_mode(mode);
- }
-
- ///
- /// Constructor
- ///
- basic_container_buffer(_CollectionType data, std::ios_base::openmode mode)
- : streambuf_state_manager(mode),
- m_data(std::move(data)),
- m_current_position((mode & std::ios_base::in) ? 0 : m_data.size())
- {
- validate_mode(mode);
- }
-
static void validate_mode(std::ios_base::openmode mode)
{
// Disallow simultaneous use of the stream buffer for writing and reading.
@@ -520,7 +518,7 @@ namespace Concurrency { namespace streams {
/// The I/O mode that the buffer should use (in / out)
container_buffer(_CollectionType data, std::ios_base::openmode mode = std::ios_base::in)
: streambuf(
- std::shared_ptr>(new streams::details::basic_container_buffer<_CollectionType>(std::move(data), mode)))
+ utility::make_shared>(std::move(data), mode))
{
}
@@ -530,7 +528,7 @@ namespace Concurrency { namespace streams {
/// The I/O mode that the buffer should use (in / out)
container_buffer(std::ios_base::openmode mode = std::ios_base::out)
: streambuf(
- std::shared_ptr>(new details::basic_container_buffer<_CollectionType>(mode)))
+ utility::make_shared>(mode))
{
}
@@ -579,7 +577,7 @@ namespace Concurrency { namespace streams {
/// The stringstream allows an input stream to be constructed from std::string or std::wstring
/// For output streams the underlying string container could be retrieved using buf->collection().
///
- typedef container_stream> stringstream;
+ typedef container_stream> stringstream;
typedef stringstream::buffer_type stringstreambuf;
typedef container_stream wstringstream;
diff --git a/Release/include/cpprest/details/basic_types.h b/Release/include/cpprest/details/basic_types.h
index eadba01684..5fc5063bd5 100644
--- a/Release/include/cpprest/details/basic_types.h
+++ b/Release/include/cpprest/details/basic_types.h
@@ -13,7 +13,12 @@
#pragma once
+#include
+#include
+#include
/// A string containing the user name.
- const utility::string_t &username() const { return m_username; }
+ const utility::wstring &username() const { return m_username; }
///
/// The password for the user name associated with the credentials.
///
/// A string containing the password.
CASABLANCA_DEPRECATED("This API is deprecated for security reasons to avoid unnecessary password copies stored in plaintext.")
- utility::string_t password() const
+ utility::secure_unique_wstring password() const
{
#if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
- return utility::string_t(*m_password.decrypt());
+ return m_password.decrypt();
#else
return m_password;
#endif
@@ -99,18 +92,25 @@ class credentials
/// true if user name and password is set, false otherwise.
bool is_set() const { return !m_username.empty(); }
- details::plaintext_string _internal_decrypt() const
+ utility::secure_unique_wstring _internal_decrypt() const
{
// Encryption APIs not supported on XP
#if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
return m_password.decrypt();
#else
- return details::plaintext_string(new ::utility::string_t(m_password));
+ return utility::make_unique>(m_password));
#endif
}
+ utility::secure_unique_string to_base64() {
+ utility::wstring userpass = m_username + _XPLATSTR(":") + _internal_decrypt()->c_str();
+ auto&& u8_userpass = utility::conversions::to_utf8string(userpass);
+ utility::vector> credentials_buffer(u8_userpass.begin(), u8_userpass.end());
+ return utility::make_unique>(utility::conversions::to_utf8string(utility::conversions::to_base64(credentials_buffer)).c_str());
+ }
+
private:
- ::utility::string_t m_username;
+ utility::wstring m_username;
#if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
#if defined(__cplusplus_winrt)
@@ -119,7 +119,7 @@ class credentials
details::win32_encryption m_password;
#endif
#else
- ::utility::string_t m_password;
+ utility::secure_wstring m_password;
#endif
};
diff --git a/Release/include/cpprest/filestream.h b/Release/include/cpprest/filestream.h
index b8b982556a..a5c65b7489 100644
--- a/Release/include/cpprest/filestream.h
+++ b/Release/include/cpprest/filestream.h
@@ -278,7 +278,7 @@ namespace details {
std::shared_ptr<_CharType> sharedCh;
try
{
- sharedCh = std::make_shared<_CharType>(ch);
+ sharedCh = utility::make_shared<_CharType>(ch);
} catch (const std::bad_alloc &)
{
delete callback;
@@ -374,7 +374,7 @@ namespace details {
{
if (copy)
{
- auto sharedData = std::make_shared>(ptr, ptr + count);
+ auto sharedData = utility::make_shared>(ptr, ptr + count);
return _putn(ptr, count).then([sharedData](size_t size)
{
return size;
@@ -715,7 +715,7 @@ namespace details {
pplx::task flush_internal()
{
pplx::task_completion_event result_tce;
- auto callback = utility::details::make_unique<_filestream_callback_write_b>(m_info, result_tce);
+ auto callback = utility::make_unique<_filestream_callback_write_b>(m_info, result_tce);
if ( !_sync_fsb(m_info, callback.get()) )
{
@@ -763,7 +763,7 @@ namespace details {
virtual void on_opened(_In_ _file_info *info)
{
- m_op.set(std::shared_ptr>(new basic_file_buffer<_CharType>(info)));
+ m_op.set(utility::make_shared>(info));
delete this;
}
diff --git a/Release/include/cpprest/http_client.h b/Release/include/cpprest/http_client.h
index f5ad8fac70..b545a887fa 100644
--- a/Release/include/cpprest/http_client.h
+++ b/Release/include/cpprest/http_client.h
@@ -112,7 +112,7 @@ class http_client_config
/// OAuth 1.0 configuration to set.
void set_oauth1(oauth1::experimental::oauth1_config config)
{
- m_oauth1 = std::make_shared(std::move(config));
+ m_oauth1 = utility::make_shared(std::move(config));
}
#endif
@@ -131,7 +131,7 @@ class http_client_config
/// OAuth 2.0 configuration to set.
void set_oauth2(oauth2::experimental::oauth2_config config)
{
- m_oauth2 = std::make_shared(std::move(config));
+ m_oauth2 = utility::make_shared(std::move(config));
}
///
@@ -561,7 +561,7 @@ class http_client
const pplx::cancellation_token &token = pplx::cancellation_token::none())
{
http_request msg(mtd);
- msg.set_request_uri(::utility::conversions::to_string_t(path_query_fragment));
+ msg.set_request_uri(utility::conversions::to_string_t(path_query_fragment));
msg.set_body(body_data, content_type);
return request(msg, token);
}
@@ -584,7 +584,7 @@ class http_client
const pplx::cancellation_token &token = pplx::cancellation_token::none())
{
http_request msg(mtd);
- msg.set_request_uri(::utility::conversions::to_string_t(path_query_fragment));
+ msg.set_request_uri(utility::conversions::to_string_t(path_query_fragment));
msg.set_body(std::move(body_data), content_type);
return request(msg, token);
}
@@ -607,7 +607,7 @@ class http_client
const pplx::cancellation_token &token = pplx::cancellation_token::none())
{
http_request msg(mtd);
- msg.set_request_uri(::utility::conversions::to_string_t(path_query_fragment));
+ msg.set_request_uri(utility::conversions::to_string_t(path_query_fragment));
msg.set_body(body_data, content_type);
return request(msg, token);
}
@@ -646,7 +646,7 @@ class http_client
const pplx::cancellation_token &token)
{
http_request msg(mtd);
- msg.set_request_uri(::utility::conversions::to_string_t(path_query_fragment));
+ msg.set_request_uri(utility::conversions::to_string_t(path_query_fragment));
msg.set_body(std::move(body_data), "text/plain; charset=utf-8");
return request(msg, token);
}
@@ -666,7 +666,7 @@ class http_client
const utf16string &body_data,
const pplx::cancellation_token &token)
{
- return request(mtd, path_query_fragment, body_data, ::utility::conversions::to_utf16string("text/plain"), token);
+ return request(mtd, path_query_fragment, body_data, utility::conversions::to_utf16string("text/plain"), token);
}
#if !defined (__cplusplus_winrt)
diff --git a/Release/include/cpprest/http_headers.h b/Release/include/cpprest/http_headers.h
index c2e35f6079..10e25221ae 100644
--- a/Release/include/cpprest/http_headers.h
+++ b/Release/include/cpprest/http_headers.h
@@ -73,7 +73,7 @@ class http_headers
};
private:
- typedef std::map inner_container;
+ typedef utility::map inner_container;
public:
///
@@ -306,7 +306,7 @@ class http_headers
return true;
}
- bool bind_impl(const key_type &text, std::string &ref) const
+ bool bind_impl(const key_type &text, utility::string &ref) const
{
ref = utility::conversions::to_utf8string(text);
return true;
diff --git a/Release/include/cpprest/http_listener.h b/Release/include/cpprest/http_listener.h
index c8059e02ba..b75ca4dd38 100644
--- a/Release/include/cpprest/http_listener.h
+++ b/Release/include/cpprest/http_listener.h
@@ -208,7 +208,7 @@ class http_listener_impl
// Handlers
std::function m_all_requests;
- std::map> m_supported_methods;
+ utility::map> m_supported_methods;
private:
@@ -242,7 +242,7 @@ class http_listener
/// The listener will not have been opened when returned.
/// URI at which the listener should accept requests.
http_listener(http::uri address)
- : m_impl(utility::details::make_unique(std::move(address)))
+ : m_impl(utility::make_unique(std::move(address)))
{
}
@@ -252,7 +252,7 @@ class http_listener
/// URI at which the listener should accept requests.
/// Configuration to create listener with.
http_listener(http::uri address, http_listener_config config)
- : m_impl(utility::details::make_unique(std::move(address), std::move(config)))
+ : m_impl(utility::make_unique(std::move(address), std::move(config)))
{
}
@@ -262,7 +262,7 @@ class http_listener
/// The resulting listener cannot be used for anything, but is useful to initialize a variable
/// that will later be overwritten with a real listener instance.
http_listener()
- : m_impl(utility::details::make_unique())
+ : m_impl(utility::make_unique())
{
}
@@ -270,7 +270,16 @@ class http_listener
/// Destructor frees any held resources.
///
/// Call close() before allowing a listener to be destroyed.
- _ASYNCRTIMP ~http_listener();
+ ~http_listener() {
+ if (m_impl) {
+ // As a safe guard close the listener if not already done.
+ // Users are required to call close, but this is just a safeguard.
+ try {
+ m_impl->close().wait();
+ } catch (...) {
+ }
+ }
+ }
///
/// Asynchronously open the listener, i.e. start accepting requests.
@@ -356,7 +365,7 @@ class http_listener
http_listener(const http_listener &other);
http_listener &operator=(const http_listener &other);
- std::unique_ptr m_impl;
+ utility::unique_ptr m_impl;
};
}}}}
diff --git a/Release/include/cpprest/http_msg.h b/Release/include/cpprest/http_msg.h
index b85e98ff42..af4153018c 100644
--- a/Release/include/cpprest/http_msg.h
+++ b/Release/include/cpprest/http_msg.h
@@ -63,12 +63,12 @@ struct http_version
/// Creates http_version from an HTTP-Version string, "HTTP" "/" 1*DIGIT "." 1*DIGIT.
///
/// Returns a http_version of {0, 0} if not successful.
- static _ASYNCRTIMP http_version __cdecl from_string(const std::string& http_version_string);
+ static _ASYNCRTIMP http_version __cdecl from_string(const utility::string& http_version_string);
///
/// Returns the string representation of the http_version.
///
- _ASYNCRTIMP std::string to_utf8string() const;
+ _ASYNCRTIMP utility::string to_utf8string() const;
};
///
@@ -200,7 +200,7 @@ class http_exception : public std::exception
/// Creates an http_exception with just a string message and no error code.
///
/// Error message string.
- http_exception(std::string whatArg) : m_msg(std::move(whatArg)) {}
+ http_exception(utility::string whatArg) : m_msg(std::move(whatArg)) {}
#endif
///
@@ -211,7 +211,7 @@ class http_exception : public std::exception
http_exception(int errorCode)
: m_errorCode(utility::details::create_error_code(errorCode))
{
- m_msg = m_errorCode.message();
+ m_msg = m_errorCode.message().c_str();
}
///
@@ -230,7 +230,7 @@ class http_exception : public std::exception
///
/// Error code value.
/// Message to use in what() string.
- http_exception(int errorCode, std::string whatArg) :
+ http_exception(int errorCode, utility::string whatArg) :
m_errorCode(utility::details::create_error_code(errorCode)),
m_msg(std::move(whatArg))
{}
@@ -244,7 +244,7 @@ class http_exception : public std::exception
/// Error category for the code.
http_exception(int errorCode, const std::error_category &cat) : m_errorCode(std::error_code(errorCode, cat))
{
- m_msg = m_errorCode.message();
+ m_msg = m_errorCode.message().c_str();
}
///
@@ -267,7 +267,7 @@ class http_exception : public std::exception
private:
std::error_code m_errorCode;
- std::string m_msg;
+ utility::string m_msg;
};
namespace details
@@ -309,7 +309,7 @@ class http_msg_base
_ASYNCRTIMP utility::string_t extract_string(bool ignore_content_type = false);
_ASYNCRTIMP json::value _extract_json(bool ignore_content_type = false);
- _ASYNCRTIMP std::vector _extract_vector();
+ _ASYNCRTIMP utility::vector _extract_vector();
virtual _ASYNCRTIMP utility::string_t to_string() const;
@@ -422,10 +422,10 @@ class _http_response final : public http::details::http_msg_base
_http_server_context * _get_server_context() const { return m_server_context.get(); }
- void _set_server_context(std::unique_ptr server_context) { m_server_context = std::move(server_context); }
+ void _set_server_context(utility::unique_ptr server_context) { m_server_context = std::move(server_context); }
private:
- std::unique_ptr<_http_server_context> m_server_context;
+ utility::unique_ptr<_http_server_context> m_server_context;
http::status_code m_status_code;
http::reason_phrase m_reason_phrase;
@@ -445,7 +445,7 @@ class http_response
/// Constructs a response with an empty status code, no headers, and no body.
///
/// A new HTTP response.
- http_response() : _m_impl(std::make_shared()) { }
+ http_response() : _m_impl(utility::make_shared()) { }
///
/// Constructs a response with given status code, no headers, and no body.
@@ -453,7 +453,7 @@ class http_response
/// HTTP status code to use in response.
/// A new HTTP response.
http_response(http::status_code code)
- : _m_impl(std::make_shared(code)) { }
+ : _m_impl(utility::make_shared(code)) { }
///
/// Gets the status code of the response message.
@@ -563,7 +563,7 @@ class http_response
/// Extracts the body of the response message into a vector of bytes.
///
/// The body of the message as a vector of bytes.
- pplx::task> extract_vector() const
+ pplx::task> extract_vector() const
{
auto impl = _m_impl;
return pplx::create_task(_m_impl->_get_data_available()).then([impl](utility::size64_t) { return impl->_extract_vector(); });
@@ -581,7 +581,7 @@ class http_response
void set_body(utf8string &&body_text, const utf8string &content_type = utf8string("text/plain; charset=utf-8"))
{
const auto length = body_text.size();
- _m_impl->set_body(concurrency::streams::bytestream::open_istream(std::move(body_text)), length, content_type);
+ _m_impl->set_body(concurrency::streams::bytestream::open_istream(std::move(body_text)), length, content_type);
}
///
@@ -595,7 +595,7 @@ class http_response
///
void set_body(const utf8string &body_text, const utf8string &content_type = utf8string("text/plain; charset=utf-8"))
{
- _m_impl->set_body(concurrency::streams::bytestream::open_istream(body_text), body_text.size(), content_type);
+ _m_impl->set_body(concurrency::streams::bytestream::open_istream(body_text), body_text.size(), content_type);
}
///
@@ -609,17 +609,17 @@ class http_response
///
void set_body(const utf16string &body_text, utf16string content_type = utility::conversions::to_utf16string("text/plain"))
{
- if (content_type.find(::utility::conversions::to_utf16string("charset=")) != content_type.npos)
+ if (content_type.find(utility::conversions::to_utf16string("charset=")) != content_type.npos)
{
throw std::invalid_argument("content_type can't contain a 'charset'.");
}
auto utf8body = utility::conversions::utf16_to_utf8(body_text);
auto length = utf8body.size();
- _m_impl->set_body(concurrency::streams::bytestream::open_istream(
+ _m_impl->set_body(concurrency::streams::bytestream::open_istream(
std::move(utf8body)),
length,
- std::move(content_type.append(::utility::conversions::to_utf16string("; charset=utf-8"))));
+ std::move(content_type.append(utility::conversions::to_utf16string("; charset=utf-8"))));
}
///
@@ -645,7 +645,7 @@ class http_response
///
/// This will overwrite any previously set body data.
///
- void set_body(std::vector &&body_data)
+ void set_body(utility::vector &&body_data)
{
auto length = body_data.size();
set_body(concurrency::streams::bytestream::open_istream(std::move(body_data)), length);
@@ -659,7 +659,7 @@ class http_response
///
/// This will overwrite any previously set body data.
///
- void set_body(const std::vector &body_data)
+ void set_body(const utility::vector &body_data)
{
set_body(concurrency::streams::bytestream::open_istream(body_data), body_data.size());
}
@@ -723,7 +723,7 @@ class http_response
std::shared_ptr _get_impl() const { return _m_impl; }
http::details::_http_server_context * _get_server_context() const { return _m_impl->_get_server_context(); }
- void _set_server_context(std::unique_ptr server_context) { _m_impl->_set_server_context(std::move(server_context)); }
+ void _set_server_context(utility::unique_ptr server_context) { _m_impl->_set_server_context(std::move(server_context)); }
private:
@@ -740,7 +740,7 @@ class _http_request final : public http::details::http_msg_base, public std::ena
_ASYNCRTIMP _http_request(http::method mtd);
- _ASYNCRTIMP _http_request(std::unique_ptr server_context);
+ _ASYNCRTIMP _http_request(utility::unique_ptr server_context);
virtual ~_http_request() {}
@@ -783,7 +783,7 @@ class _http_request final : public http::details::http_msg_base, public std::ena
void set_progress_handler(const progress_handler &handler)
{
- m_progress_handler = std::make_shared(handler);
+ m_progress_handler = utility::make_shared(handler);
}
const concurrency::streams::ostream & _response_stream() const { return m_response_stream; }
@@ -792,7 +792,7 @@ class _http_request final : public http::details::http_msg_base, public std::ena
http::details::_http_server_context * _get_server_context() const { return m_server_context.get(); }
- void _set_server_context(std::unique_ptr server_context) { m_server_context = std::move(server_context); }
+ void _set_server_context(utility::unique_ptr server_context) { m_server_context = std::move(server_context); }
void _set_listener_path(const utility::string_t &path) { m_listener_path = path; }
@@ -812,7 +812,7 @@ class _http_request final : public http::details::http_msg_base, public std::ena
// Tracks whether or not a response has already been started for this message.
pplx::details::atomic_long m_initiated_response;
- std::unique_ptr m_server_context;
+ utility::unique_ptr m_server_context;
pplx::cancellation_token m_cancellationToken;
@@ -844,14 +844,14 @@ class http_request
/// Constructs a new HTTP request with the 'GET' method.
///
http_request()
- : _m_impl(std::make_shared(methods::GET)) {}
+ : _m_impl(utility::make_shared(methods::GET)) {}
///
/// Constructs a new HTTP request with the given request method.
///
/// Request method.
http_request(http::method mtd)
- : _m_impl(std::make_shared(std::move(mtd))) {}
+ : _m_impl(utility::make_shared(std::move(mtd))) {}
///
/// Destructor frees any held resources.
@@ -987,7 +987,7 @@ class http_request
/// Extract the body of the response message into a vector of bytes. Extracting a vector can be done on
///
/// The body of the message as a vector of bytes.
- pplx::task> extract_vector() const
+ pplx::task> extract_vector() const
{
auto impl = _m_impl;
return pplx::create_task(_m_impl->_get_data_available()).then([impl](utility::size64_t) { return impl->_extract_vector(); });
@@ -1005,7 +1005,7 @@ class http_request
void set_body(utf8string &&body_text, const utf8string &content_type = utf8string("text/plain; charset=utf-8"))
{
const auto length = body_text.size();
- _m_impl->set_body(concurrency::streams::bytestream::open_istream(std::move(body_text)), length, content_type);
+ _m_impl->set_body(concurrency::streams::bytestream::open_istream(std::move(body_text)), length, content_type);
}
///
@@ -1019,7 +1019,7 @@ class http_request
///
void set_body(const utf8string &body_text, const utf8string &content_type = utf8string("text/plain; charset=utf-8"))
{
- _m_impl->set_body(concurrency::streams::bytestream::open_istream(body_text), body_text.size(), content_type);
+ _m_impl->set_body(concurrency::streams::bytestream::open_istream(body_text), body_text.size(), content_type);
}
///
@@ -1034,7 +1034,7 @@ class http_request
///
void set_body(const utf16string &body_text, utf16string content_type = utility::conversions::to_utf16string("text/plain"))
{
- if(content_type.find(::utility::conversions::to_utf16string("charset=")) != content_type.npos)
+ if(content_type.find(utility::conversions::to_utf16string("charset=")) != content_type.npos)
{
throw std::invalid_argument("content_type can't contain a 'charset'.");
}
@@ -1044,7 +1044,7 @@ class http_request
_m_impl->set_body(concurrency::streams::bytestream::open_istream(
std::move(utf8body)),
length,
- std::move(content_type.append(::utility::conversions::to_utf16string("; charset=utf-8"))));
+ std::move(content_type.append(utility::conversions::to_utf16string("; charset=utf-8"))));
}
///
@@ -1070,7 +1070,7 @@ class http_request
///
/// This will overwrite any previously set body data.
///
- void set_body(std::vector &&body_data)
+ void set_body(utility::vector &&body_data)
{
auto length = body_data.size();
_m_impl->set_body(concurrency::streams::bytestream::open_istream(std::move(body_data)), length, _XPLATSTR("application/octet-stream"));
@@ -1084,7 +1084,7 @@ class http_request
///
/// This will overwrite any previously set body data.
///
- void set_body(const std::vector &body_data)
+ void set_body(const utility::vector &body_data)
{
set_body(concurrency::streams::bytestream::open_istream(body_data), body_data.size());
}
@@ -1341,8 +1341,8 @@ class http_request
///
/// These are used for the initial creation of the HTTP request.
///
- static http_request _create_request(std::unique_ptr server_context) { return http_request(std::move(server_context)); }
- void _set_server_context(std::unique_ptr server_context) { _m_impl->_set_server_context(std::move(server_context)); }
+ static http_request _create_request(utility::unique_ptr server_context) { return http_request(std::move(server_context)); }
+ void _set_server_context(utility::unique_ptr server_context) { _m_impl->_set_server_context(std::move(server_context)); }
void _set_listener_path(const utility::string_t &path) { _m_impl->_set_listener_path(path); }
@@ -1367,7 +1367,7 @@ class http_request
friend class http::details::_http_request;
friend class http::client::http_client;
- http_request(std::unique_ptr server_context) : _m_impl(std::make_shared(std::move(server_context))) {}
+ http_request(utility::unique_ptr server_context) : _m_impl(utility::make_shared(std::move(server_context))) {}
std::shared_ptr _m_impl;
};
diff --git a/Release/include/cpprest/interopstream.h b/Release/include/cpprest/interopstream.h
index 5cf575aa0e..1d381227fa 100644
--- a/Release/include/cpprest/interopstream.h
+++ b/Release/include/cpprest/interopstream.h
@@ -134,7 +134,7 @@ namespace Concurrency { namespace streams {
/// The synchronous stream that this is using for its I/O
template
stdio_ostream(std::basic_ostream& stream)
- : basic_ostream(streams::streambuf(std::shared_ptr>(new details::basic_stdio_buffer(stream.rdbuf(), std::ios_base::out))))
+ : basic_ostream(utility::make_shared>(stream.rdbuf(), std::ios_base::out))
{
}
@@ -178,7 +178,7 @@ namespace Concurrency { namespace streams {
/// The synchronous stream that this is using for its I/O
template
stdio_istream(std::basic_istream& stream)
- : basic_istream(streams::streambuf(std::shared_ptr>(new details::basic_stdio_buffer(stream.rdbuf(), std::ios_base::in))))
+ : basic_istream(utility::make_shared>(stream.rdbuf(), std::ios_base::in))
{
}
diff --git a/Release/include/cpprest/json.h b/Release/include/cpprest/json.h
index dfdeead4f3..42340c1881 100644
--- a/Release/include/cpprest/json.h
+++ b/Release/include/cpprest/json.h
@@ -284,7 +284,7 @@ namespace json
#ifdef _WIN32
private:
// Only used internally by JSON parser.
- static _ASYNCRTIMP value __cdecl string(const std::string &value);
+ static _ASYNCRTIMP value __cdecl string(const utility::string &value);
public:
#endif
@@ -301,7 +301,7 @@ namespace json
/// Field names associated with JSON values
/// Whether to preserve the original order of the fields
/// A non-empty JSON object value
- static _ASYNCRTIMP json::value __cdecl object(std::vector> fields, bool keep_order = false);
+ static _ASYNCRTIMP json::value __cdecl object(utility::vector> fields, bool keep_order = false);
///
/// Creates an empty JSON array
@@ -321,7 +321,7 @@ namespace json
///
/// A vector of JSON values
/// A JSON array value
- static _ASYNCRTIMP json::value __cdecl array(std::vector elements);
+ static _ASYNCRTIMP json::value __cdecl array(utility::vector elements);
///
/// Accesses the type of JSON value the current value instance is
@@ -651,7 +651,7 @@ namespace json
#ifdef _WIN32
private:
// Only used internally by JSON parser
- _ASYNCRTIMP value & operator [] (const std::string &key)
+ _ASYNCRTIMP value & operator [] (const utility::string &key)
{
// JSON object stores its field map as a unordered_map of string_t, so this conversion is hard to avoid
return operator[](utility::conversions::to_string_t(key));
@@ -684,22 +684,22 @@ namespace json
/// Writes the current JSON value as a double-byte string to a string instance.
///
/// The string that the JSON representation should be written to.
- _ASYNCRTIMP void format(std::basic_string &string) const;
+ _ASYNCRTIMP void format(utility::basic_string &string) const;
#endif
///
/// Serializes the content of the value into a string instance in UTF8 format
///
/// The string that the JSON representation should be written to
- _ASYNCRTIMP void format(std::basic_string& string) const;
+ _ASYNCRTIMP void format(utility::string& string) const;
#ifdef ENABLE_JSON_VALUE_VISUALIZER
- explicit value(std::unique_ptr v, value_type kind) : m_value(std::move(v)), m_kind(kind)
+ explicit value(utility::unique_ptr v, value_type kind) : m_value(std::move(v)), m_kind(kind)
#else
- explicit value(std::unique_ptr v) : m_value(std::move(v))
+ explicit value(utility::unique_ptr v) : m_value(std::move(v))
#endif
{}
- std::unique_ptr m_value;
+ utility::unique_ptr m_value;
#ifdef ENABLE_JSON_VALUE_VISUALIZER
value_type m_kind;
#endif
@@ -712,7 +712,7 @@ namespace json
class json_exception : public std::exception
{
private:
- std::string _message;
+ utility::string _message;
public:
json_exception(const utility::char_t * const &message) : _message(utility::conversions::to_utf8string(message)) { }
@@ -788,7 +788,7 @@ namespace json
///
class array
{
- typedef std::vector storage_type;
+ typedef utility::vector storage_type;
public:
typedef storage_type::iterator iterator;
@@ -998,7 +998,7 @@ namespace json
///
class object
{
- typedef std::vector> storage_type;
+ typedef utility::vector> storage_type;
public:
typedef storage_type::iterator iterator;
@@ -1461,7 +1461,7 @@ namespace json
class _Value
{
public:
- virtual std::unique_ptr<_Value> _copy_value() = 0;
+ virtual utility::unique_ptr<_Value> _copy_value() = 0;
virtual bool has_field(const utility::string_t &) const { return false; }
virtual value get_field(const utility::string_t &) const { throw json_exception(_XPLATSTR("not an object")); }
@@ -1474,12 +1474,12 @@ namespace json
virtual const value &cnst_index(array::size_type) const { throw json_exception(_XPLATSTR("not an array")); }
// Common function used for serialization to strings and streams.
- virtual void serialize_impl(std::string& str) const
+ virtual void serialize_impl(utility::string& str) const
{
format(str);
}
#ifdef _WIN32
- virtual void serialize_impl(std::wstring& str) const
+ virtual void serialize_impl(utility::wstring& str) const
{
format(str);
}
@@ -1514,12 +1514,12 @@ namespace json
protected:
_Value() {}
- virtual void format(std::basic_string& stream) const
+ virtual void format(utility::string& stream) const
{
stream.append("null");
}
#ifdef _WIN32
- virtual void format(std::basic_string& stream) const
+ virtual void format(utility::wstring& stream) const
{
stream.append(L"null");
}
@@ -1532,9 +1532,9 @@ namespace json
class _Null : public _Value
{
public:
- virtual std::unique_ptr<_Value> _copy_value()
+ virtual utility::unique_ptr<_Value> _copy_value()
{
- return utility::details::make_unique<_Null>();
+ return utility::make_unique<_Null>();
}
virtual json::value::value_type type() const { return json::value::Null; }
};
@@ -1548,9 +1548,9 @@ namespace json
_Number(int64_t value) : m_number(value) { }
_Number(uint64_t value) : m_number(value) { }
- virtual std::unique_ptr<_Value> _copy_value()
+ virtual utility::unique_ptr<_Value> _copy_value()
{
- return utility::details::make_unique<_Number>(*this);
+ return utility::make_unique<_Number>(*this);
}
virtual json::value::value_type type() const { return json::value::Number; }
@@ -1571,9 +1571,9 @@ namespace json
virtual const number& as_number() { return m_number; }
protected:
- virtual void format(std::basic_string& stream) const ;
+ virtual void format(utility::string& stream) const ;
#ifdef _WIN32
- virtual void format(std::basic_string& stream) const;
+ virtual void format(utility::wstring& stream) const;
#endif
private:
template friend class json::details::JSON_Parser;
@@ -1586,9 +1586,9 @@ namespace json
public:
_Boolean(bool value) : m_value(value) { }
- virtual std::unique_ptr<_Value> _copy_value()
+ virtual utility::unique_ptr<_Value> _copy_value()
{
- return utility::details::make_unique<_Boolean>(*this);
+ return utility::make_unique<_Boolean>(*this);
}
virtual json::value::value_type type() const { return json::value::Boolean; }
@@ -1596,13 +1596,13 @@ namespace json
virtual bool as_bool() const { return m_value; }
protected:
- virtual void format(std::basic_string& stream) const
+ virtual void format(utility::string& stream) const
{
stream.append(m_value ? "true" : "false");
}
#ifdef _WIN32
- virtual void format(std::basic_string& stream) const
+ virtual void format(utility::wstring& stream) const
{
stream.append(m_value ? L"true" : L"false");
}
@@ -1626,40 +1626,40 @@ namespace json
{ }
#ifdef _WIN32
- _String(std::string &&value) : m_string(utility::conversions::to_utf16string(std::move(value)))
+ _String(utility::string &&value) : m_string(utility::conversions::to_utf16string(std::move(value)))
{
m_has_escape_char = has_escape_chars(*this);
}
- _String(std::string &&value, bool escape_chars)
+ _String(utility::string &&value, bool escape_chars)
: m_string(utility::conversions::to_utf16string(std::move(value))),
m_has_escape_char(escape_chars)
{ }
#endif
- virtual std::unique_ptr<_Value> _copy_value()
+ virtual utility::unique_ptr<_Value> _copy_value()
{
- return utility::details::make_unique<_String>(*this);
+ return utility::make_unique<_String>(*this);
}
virtual json::value::value_type type() const { return json::value::String; }
virtual const utility::string_t & as_string() const;
- virtual void serialize_impl(std::string& str) const
+ virtual void serialize_impl(utility::string& str) const
{
serialize_impl_char_type(str);
}
#ifdef _WIN32
- virtual void serialize_impl(std::wstring& str) const
+ virtual void serialize_impl(utility::wstring& str) const
{
serialize_impl_char_type(str);
}
#endif
protected:
- virtual void format(std::basic_string& str) const;
+ virtual void format(utility::string& str) const;
#ifdef _WIN32
- virtual void format(std::basic_string& str) const;
+ virtual void format(utility::wstring& str) const;
#endif
private:
@@ -1672,7 +1672,7 @@ namespace json
}
template
- void serialize_impl_char_type(std::basic_string& str) const
+ void serialize_impl_char_type(utility::basic_string& str) const
{
// To avoid repeated allocations reserve some space all up front.
// size of string + 2 for quotes
@@ -1680,7 +1680,7 @@ namespace json
format(str);
}
- std::string as_utf8_string() const;
+ utility::string as_utf8_string() const;
utf16string as_utf16_string() const;
utility::string_t m_string;
@@ -1692,12 +1692,12 @@ namespace json
};
template
- _ASYNCRTIMP void append_escape_string(std::basic_string& str, const std::basic_string& escaped);
+ _ASYNCRTIMP void append_escape_string(utility::basic_string& str, const utility::basic_string& escaped);
void format_string(const utility::string_t& key, utility::string_t& str);
#ifdef _WIN32
- void format_string(const utility::string_t& key, std::string& str);
+ void format_string(const utility::string_t& key, utility::string& str);
#endif
class _Object : public _Value
@@ -1707,9 +1707,9 @@ namespace json
_Object(bool keep_order) : m_object(keep_order) { }
_Object(object::storage_type fields, bool keep_order) : m_object(std::move(fields), keep_order) { }
- virtual std::unique_ptr<_Value> _copy_value()
+ virtual utility::unique_ptr<_Value> _copy_value()
{
- return utility::details::make_unique<_Object>(*this);
+ return utility::make_unique<_Object>(*this);
}
virtual json::object& as_object() { return m_object; }
@@ -1730,14 +1730,14 @@ namespace json
return std::equal(std::begin(m_object), std::end(m_object), std::begin(other->m_object));
}
- virtual void serialize_impl(std::string& str) const
+ virtual void serialize_impl(utility::string& str) const
{
// To avoid repeated allocations reserve some space all up front.
str.reserve(get_reserve_size());
format(str);
}
#ifdef _WIN32
- virtual void serialize_impl(std::wstring& str) const
+ virtual void serialize_impl(utility::wstring& str) const
{
// To avoid repeated allocations reserve some space all up front.
str.reserve(get_reserve_size());
@@ -1747,12 +1747,12 @@ namespace json
size_t size() const { return m_object.size(); }
protected:
- virtual void format(std::basic_string& str) const
+ virtual void format(utility::string& str) const
{
format_impl(str);
}
#ifdef _WIN32
- virtual void format(std::basic_string& str) const
+ virtual void format(utility::wstring& str) const
{
format_impl(str);
}
@@ -1764,7 +1764,7 @@ namespace json
template friend class json::details::JSON_Parser;
template
- void format_impl(std::basic_string& str) const
+ void format_impl(utility::basic_string& str) const
{
str.push_back('{');
if(!m_object.empty())
@@ -1818,9 +1818,9 @@ namespace json
_Array(array::size_type size) : m_array(size) {}
_Array(array::storage_type elements) : m_array(std::move(elements)) { }
- virtual std::unique_ptr<_Value> _copy_value()
+ virtual utility::unique_ptr<_Value> _copy_value()
{
- return utility::details::make_unique<_Array>(*this);
+ return utility::make_unique<_Array>(*this);
}
virtual json::value::value_type type() const { return json::value::Array; }
@@ -1852,14 +1852,14 @@ namespace json
return true;
}
- virtual void serialize_impl(std::string& str) const
+ virtual void serialize_impl(utility::string& str) const
{
// To avoid repeated allocations reserve some space all up front.
str.reserve(get_reserve_size());
format(str);
}
#ifdef _WIN32
- virtual void serialize_impl(std::wstring& str) const
+ virtual void serialize_impl(utility::wstring& str) const
{
// To avoid repeated allocations reserve some space all up front.
str.reserve(get_reserve_size());
@@ -1869,12 +1869,12 @@ namespace json
size_t size() const { return m_array.size(); }
protected:
- virtual void format(std::basic_string& str) const
+ virtual void format(utility::string& str) const
{
format_impl(str);
}
#ifdef _WIN32
- virtual void format(std::basic_string& str) const
+ virtual void format(utility::wstring& str) const
{
format_impl(str);
}
@@ -1885,7 +1885,7 @@ namespace json
template friend class json::details::JSON_Parser;
template
- void format_impl(std::basic_string& str) const
+ void format_impl(utility::basic_string& str) const
{
str.push_back('[');
if(!m_array.m_elements.empty())
diff --git a/Release/include/cpprest/oauth1.h b/Release/include/cpprest/oauth1.h
index 24a10c7d79..6a9c87d4b1 100644
--- a/Release/include/cpprest/oauth1.h
+++ b/Release/include/cpprest/oauth1.h
@@ -114,7 +114,7 @@ class oauth1_exception : public std::exception
const char* what() const CPPREST_NOEXCEPT { return m_msg.c_str(); }
private:
- std::string m_msg;
+ utility::string m_msg;
};
///
@@ -186,7 +186,7 @@ class oauth1_token
/// Retrieves any additional parameters.
///
/// A map containing the additional parameters.
- const std::map &additional_parameters() const { return m_additional_parameters; }
+ const utility::map &additional_parameters() const { return m_additional_parameters; }
///
/// Sets a specific parameter additional parameter.
@@ -218,7 +218,7 @@ class oauth1_token
utility::string_t m_token;
utility::string_t m_secret;
- std::map m_additional_parameters;
+ utility::map m_additional_parameters;
};
///
@@ -437,7 +437,7 @@ class oauth1_config
/// Gets map of parameters to sign.
///
/// Map of parameters.
- const std::map& parameters() const { return m_parameters_to_sign; }
+ const utility::map& parameters() const { return m_parameters_to_sign; }
///
/// Adds a key value parameter.
@@ -457,7 +457,7 @@ class oauth1_config
/// Sets entire map or parameters replacing all previously values.
///
/// Map of values.
- void set_parameters(const std::map ¶meters)
+ void set_parameters(const utility::map ¶meters)
{
m_parameters_to_sign.clear();
m_parameters_to_sign = parameters;
@@ -504,7 +504,7 @@ class oauth1_config
return utility::conversions::details::to_string_t(utility::datetime::utc_timestamp());
}
- _ASYNCRTIMP static std::vector __cdecl _hmac_sha1(const utility::string_t& key, const utility::string_t& data);
+ _ASYNCRTIMP static utility::vector __cdecl _hmac_sha1(const utility::string_t& key, const utility::string_t& data);
static utility::string_t _build_base_string_uri(const uri& u);
@@ -537,7 +537,7 @@ class oauth1_config
utility::string_t m_realm;
oauth1_method m_method;
- std::map m_parameters_to_sign;
+ utility::map m_parameters_to_sign;
web::web_proxy m_proxy;
diff --git a/Release/include/cpprest/oauth2.h b/Release/include/cpprest/oauth2.h
index 7afccdc3e1..e990977b6d 100644
--- a/Release/include/cpprest/oauth2.h
+++ b/Release/include/cpprest/oauth2.h
@@ -65,7 +65,7 @@ class oauth2_exception : public std::exception
const char* what() const CPPREST_NOEXCEPT { return m_msg.c_str(); }
private:
- std::string m_msg;
+ utility::string m_msg;
};
///
diff --git a/Release/include/cpprest/producerconsumerstream.h b/Release/include/cpprest/producerconsumerstream.h
index 4e10872f45..03d7c9390e 100644
--- a/Release/include/cpprest/producerconsumerstream.h
+++ b/Release/include/cpprest/producerconsumerstream.h
@@ -150,7 +150,7 @@ namespace Concurrency { namespace streams {
// easier book keeping
_ASSERTE(!m_allocBlock);
- m_allocBlock = std::make_shared<_block>(count);
+ m_allocBlock = utility::make_shared<_block>(count);
return m_allocBlock->wbegin();
}
@@ -379,7 +379,7 @@ namespace Concurrency { namespace streams {
if ( m_blocks.empty() || m_blocks.back()->wr_chars_left() < count )
{
msl::safeint3::SafeInt alloc = m_alloc_size.Max(count);
- m_blocks.push_back(std::make_shared<_block>(alloc));
+ m_blocks.push_back(utility::make_shared<_block>(alloc));
}
// The block at the back is always the write head
@@ -659,10 +659,10 @@ namespace Concurrency { namespace streams {
pplx::extensibility::critical_section_t m_lock;
// Memory blocks
- std::deque> m_blocks;
+ utility::deque> m_blocks;
// Queue of requests
- std::queue<_request> m_requests;
+ utility::queue<_request> m_requests;
};
} // namespace details
@@ -687,7 +687,7 @@ namespace Concurrency { namespace streams {
///
/// The internal default block size.
producer_consumer_buffer(size_t alloc_size = 512)
- : streambuf<_CharType>(std::make_shared>(alloc_size))
+ : streambuf<_CharType>(utility::make_shared>(alloc_size))
{
}
};
diff --git a/Release/include/cpprest/rawptrstream.h b/Release/include/cpprest/rawptrstream.h
index 3fdbb99cb3..bcf8a97910 100644
--- a/Release/include/cpprest/rawptrstream.h
+++ b/Release/include/cpprest/rawptrstream.h
@@ -58,6 +58,33 @@ namespace Concurrency { namespace streams {
{
}
+ ///
+ /// Constructor
+ ///
+ /// The address (pointer to) the memory block.
+ /// The memory block size, measured in number of characters.
+ basic_rawptr_buffer(const _CharType* data, size_t size)
+ : streambuf_state_manager<_CharType>(std::ios_base::in),
+ m_data(const_cast<_CharType*>(data)),
+ m_size(size),
+ m_current_position(0) {
+ validate_mode(std::ios_base::in);
+ }
+
+ ///
+ /// Constructor
+ ///
+ /// The address (pointer to) the memory block.
+ /// The memory block size, measured in number of characters.
+ /// The stream mode (in, out, etc.).
+ basic_rawptr_buffer(_CharType* data, size_t size, std::ios_base::openmode mode)
+ : streambuf_state_manager<_CharType>(mode),
+ m_data(data),
+ m_size(size),
+ m_current_position(0) {
+ validate_mode(mode);
+ }
+
///
/// Destructor
///
@@ -397,35 +424,6 @@ namespace Concurrency { namespace streams {
private:
template friend class ::concurrency::streams::rawptr_buffer;
- ///
- /// Constructor
- ///
- /// The address (pointer to) the memory block.
- /// The memory block size, measured in number of characters.
- basic_rawptr_buffer(const _CharType* data, size_t size)
- : streambuf_state_manager<_CharType>(std::ios_base::in),
- m_data(const_cast<_CharType*>(data)),
- m_size(size),
- m_current_position(0)
- {
- validate_mode(std::ios_base::in);
- }
-
- ///
- /// Constructor
- ///
- /// The address (pointer to) the memory block.
- /// The memory block size, measured in number of characters.
- /// The stream mode (in, out, etc.).
- basic_rawptr_buffer(_CharType* data, size_t size, std::ios_base::openmode mode)
- : streambuf_state_manager<_CharType>(mode),
- m_data(data),
- m_size(size),
- m_current_position(0)
- {
- validate_mode(mode);
- }
-
static void validate_mode(std::ios_base::openmode mode)
{
// Disallow simultaneous use of the stream buffer for writing and reading.
@@ -555,7 +553,7 @@ namespace Concurrency { namespace streams {
/// The address (pointer to) the memory block.
/// The memory block size, measured in number of characters.
rawptr_buffer(const char_type* data, size_t size)
- : streambuf(std::shared_ptr>(new details::basic_rawptr_buffer(data, size)))
+ : streambuf(utility::make_shared>(data, size))
{
}
@@ -565,7 +563,7 @@ namespace Concurrency { namespace streams {
/// The address (pointer to) the memory block.
/// The memory block size, measured in number of characters.
rawptr_buffer(char_type* data, size_t size, std::ios_base::openmode mode = std::ios::out)
- : streambuf(std::shared_ptr>(new details::basic_rawptr_buffer(data, size, mode)))
+ : streambuf(utility::make_shared>(data, size, mode))
{
}
diff --git a/Release/include/cpprest/streams.h b/Release/include/cpprest/streams.h
index d2923d3774..0b03d9dff7 100644
--- a/Release/include/cpprest/streams.h
+++ b/Release/include/cpprest/streams.h
@@ -56,9 +56,9 @@ namespace Concurrency { namespace streams
struct Value2StringFormatter
{
template
- static std::basic_string format(const T &val)
+ static utility::basic_string format(const T &val)
{
- std::basic_ostringstream ss;
+ utility::basic_ostringstream ss;
ss << val;
return ss.str();
}
@@ -68,14 +68,14 @@ namespace Concurrency { namespace streams
struct Value2StringFormatter
{
template
- static std::basic_string format(const T &val)
+ static utility::basic_string format(const T &val)
{
- std::basic_ostringstream ss;
+ utility::basic_ostringstream ss;
ss << val;
return reinterpret_cast(ss.str().c_str());
}
- static std::basic_string format(const utf16string &val)
+ static utility::basic_string format(const utf16string &val)
{
return format(utility::conversions::utf16_to_utf8(val));
}
@@ -123,7 +123,7 @@ namespace Concurrency { namespace streams
///
/// A stream buffer.
basic_ostream(streams::streambuf buffer) :
- m_helper(std::make_shared>(buffer))
+ m_helper(utility::make_shared>(buffer))
{
_verify_and_throw(details::_out_streambuf_msg);
}
@@ -182,7 +182,7 @@ namespace Concurrency { namespace streams
pplx::task result;
if ( !_verify_and_return_task(details::_out_stream_msg, result) ) return result;
- auto copy = std::make_shared(std::move(value));
+ auto copy = utility::make_shared(std::move(value));
return helper()->m_buffer.putn_nocopy((CharType*)copy.get(), sizeof(T)).then([copy](pplx::task op) -> size_t { return op.get(); });
}
@@ -262,7 +262,7 @@ namespace Concurrency { namespace streams
/// Write the specified string to the output stream.
///
/// Input string.
- pplx::task print(const std::basic_string& str) const
+ pplx::task print(const utility::basic_string& str) const
{
pplx::task result;
if ( !_verify_and_return_task(details::_out_stream_msg, result) ) return result;
@@ -273,7 +273,7 @@ namespace Concurrency { namespace streams
}
else
{
- auto sharedStr = std::make_shared>(str);
+ auto sharedStr = utility::make_shared>(str);
return helper()->m_buffer.putn_nocopy(sharedStr->c_str(), sharedStr->size()).then([sharedStr](size_t size) { return size; });
}
}
@@ -578,7 +578,7 @@ namespace Concurrency { namespace streams
///
/// A stream buffer.
template
- basic_istream(streams::streambuf buffer) : m_helper(std::make_shared>(std::move(buffer)))
+ basic_istream(streams::streambuf buffer) : m_helper(utility::make_shared>(std::move(buffer)))
{
_verify_and_throw(details::_in_streambuf_msg);
}
@@ -663,7 +663,7 @@ namespace Concurrency { namespace streams
pplx::task result;
if ( !_verify_and_return_task(details::_in_stream_msg, result) ) return result;
- auto copy = std::make_shared();
+ auto copy = utility::make_shared();
return helper()->m_buffer.getn((CharType*)copy.get(), sizeof(T)).then([copy](pplx::task) -> T
{
return std::move(*copy);
@@ -772,7 +772,7 @@ namespace Concurrency { namespace streams
int_type req_async = traits::requires_async();
- std::shared_ptr<_read_helper> _locals = std::make_shared<_read_helper>();
+ std::shared_ptr<_read_helper> _locals = utility::make_shared<_read_helper>();
auto flush = [=]() mutable
{
@@ -844,7 +844,7 @@ namespace Concurrency { namespace streams
int_type req_async = traits::requires_async();
- std::shared_ptr<_read_helper> _locals = std::make_shared<_read_helper>();
+ std::shared_ptr<_read_helper> _locals = utility::make_shared<_read_helper>();
auto flush = [=]() mutable
{
@@ -941,7 +941,7 @@ namespace Concurrency { namespace streams
auto l_buffer = helper()->m_buffer;
auto l_buf_size = this->buf_size;
- std::shared_ptr<_read_helper> l_locals = std::make_shared<_read_helper>();
+ std::shared_ptr<_read_helper> l_locals = utility::make_shared<_read_helper>();
auto copy_to_target = [l_locals, target, l_buffer, l_buf_size]() mutable -> pplx::task
{
@@ -1173,7 +1173,7 @@ pplx::task _type_parser_base::_parse_input(
AcceptFunctor accept_character,
ExtractFunctor extract)
{
- std::shared_ptr state = std::make_shared();
+ std::shared_ptr state = utility::make_shared();
auto update = [=] (pplx::task op) -> pplx::task
{
@@ -1223,26 +1223,26 @@ pplx::task _type_parser_base::_parse_input(
}
template
-class type_parser> : public _type_parser_base
+class type_parser> : public _type_parser_base
{
typedef _type_parser_base base;
public:
typedef typename base::traits traits;
typedef typename base::int_type int_type;
- static pplx::task parse(streams::streambuf buffer)
+ static pplx::task parse(streams::streambuf buffer)
{
- return base::template _parse_input, std::string>(buffer, _accept_char, _extract_result);
+ return base::template _parse_input, utility::string>(buffer, _accept_char, _extract_result);
}
private:
- static bool _accept_char(std::shared_ptr> state, int_type ch)
+ static bool _accept_char(std::shared_ptr> state, int_type ch)
{
if ( ch == traits::eof() || isspace(ch)) return false;
state->push_back(CharType(ch));
return true;
}
- static pplx::task> _extract_result(std::shared_ptr> state)
+ static pplx::task> _extract_result(std::shared_ptr> state)
{
return pplx::task_from_result(*state);
}
@@ -1739,26 +1739,26 @@ class type_parser : public _type_parser_base
#ifdef _WIN32
template
-class type_parser>> : public _type_parser_base
+class type_parser>> : public _type_parser_base
{
typedef _type_parser_base base;
public:
typedef typename base::traits traits;
typedef typename base::int_type int_type;
- static pplx::task parse(streams::streambuf buffer)
+ static pplx::task parse(streams::streambuf buffer)
{
- return base::template _parse_input,std::basic_string>(buffer, _accept_char, _extract_result);
+ return base::template _parse_input,utility::basic_string>(buffer, _accept_char, _extract_result);
}
private:
- static bool _accept_char(const std::shared_ptr> &state, int_type ch)
+ static bool _accept_char(const std::shared_ptr> &state, int_type ch)
{
if ( ch == concurrency::streams::char_traits::eof() || isspace(ch)) return false;
state->push_back(char(ch));
return true;
}
- static pplx::task> _extract_result(std::shared_ptr> state)
+ static pplx::task> _extract_result(std::shared_ptr> state)
{
return pplx::task_from_result(utility::conversions::utf8_to_utf16(*state));
}
diff --git a/Release/include/cpprest/ws_client.h b/Release/include/cpprest/ws_client.h
index 98f933e149..24087d2c6f 100644
--- a/Release/include/cpprest/ws_client.h
+++ b/Release/include/cpprest/ws_client.h
@@ -176,7 +176,7 @@ class websocket_client_config
///
/// The name of the subprotocol.
/// If additional subprotocols have already been specified, the new one will just be added.
- _ASYNCRTIMP void add_subprotocol(const ::utility::string_t &name);
+ _ASYNCRTIMP void add_subprotocol(const utility::string_t &name);
///
/// Gets list of the specified subprotocols.
@@ -184,7 +184,7 @@ class websocket_client_config
/// Vector of all the subprotocols
/// If you want all the subprotocols in a comma separated string
/// they can be directly looked up in the headers using 'Sec-WebSocket-Protocol'.
- _ASYNCRTIMP std::vector< ::utility::string_t> subprotocols() const;
+ _ASYNCRTIMP utility::vector subprotocols() const;
///
/// Gets the server certificate validation property.
@@ -233,7 +233,7 @@ class websocket_exception : public std::exception
/// Creates an websocket_exception with just a string message and no error code.
///
/// Error message string.
- websocket_exception(std::string whatArg) : m_msg(std::move(whatArg)) {}
+ websocket_exception(utility::string whatArg) : m_msg(std::move(whatArg)) {}
#endif
///
@@ -244,7 +244,7 @@ class websocket_exception : public std::exception
websocket_exception(int errorCode)
: m_errorCode(utility::details::create_error_code(errorCode))
{
- m_msg = m_errorCode.message();
+ m_msg = m_errorCode.message().c_str();
}
///
@@ -263,7 +263,7 @@ class websocket_exception : public std::exception
///
/// Error code value.
/// Message to use in what() string.
- websocket_exception(int errorCode, std::string whatArg)
+ websocket_exception(int errorCode, utility::string whatArg)
: m_errorCode(utility::details::create_error_code(errorCode)),
m_msg(std::move(whatArg))
{}
@@ -273,7 +273,7 @@ class websocket_exception : public std::exception
/// Error code.
/// Message to use in what() string.
///
- websocket_exception(std::error_code code, std::string whatArg) :
+ websocket_exception(std::error_code code, utility::string whatArg) :
m_errorCode(std::move(code)),
m_msg(std::move(whatArg))
{}
@@ -287,7 +287,7 @@ class websocket_exception : public std::exception
/// Error category for the code.
websocket_exception(int errorCode, const std::error_category &cat) : m_errorCode(std::error_code(errorCode, cat))
{
- m_msg = m_errorCode.message();
+ m_msg = m_errorCode.message().c_str();
}
///
@@ -320,7 +320,7 @@ class websocket_exception : public std::exception
private:
std::error_code m_errorCode;
- std::string m_msg;
+ utility::string m_msg;
};
namespace details
@@ -413,9 +413,9 @@ class websocket_client_task_impl
// m_receive_queue_lock : to guard access to the queue & m_client_closed
std::mutex m_receive_queue_lock;
// Queue to store incoming messages when there are no tasks waiting for a message
- std::queue m_receive_msg_queue;
+ utility::queue m_receive_msg_queue;
// Queue to maintain the receive tasks when there are no messages(yet).
- std::queue> m_receive_task_queue;
+ utility::queue> m_receive_task_queue;
// Initially set to false, becomes true if a close frame is received from the server or
// if the underlying connection is aborted or terminated.
@@ -435,7 +435,7 @@ class websocket_client
/// Creates a new websocket_client.
///
websocket_client() :
- m_client(std::make_shared(websocket_client_config()))
+ m_client(utility::make_shared(websocket_client_config()))
{}
///
@@ -443,7 +443,7 @@ class websocket_client
///
/// The client configuration object containing the possible configuration options to initialize the websocket_client.
websocket_client(websocket_client_config config) :
- m_client(std::make_shared(std::move(config)))
+ m_client(utility::make_shared(std::move(config)))
{}
///
diff --git a/Release/include/cpprest/ws_msg.h b/Release/include/cpprest/ws_msg.h
index 326541c7a1..8e10b09223 100644
--- a/Release/include/cpprest/ws_msg.h
+++ b/Release/include/cpprest/ws_msg.h
@@ -76,18 +76,18 @@ class websocket_outgoing_message
/// Sets a UTF-8 message as the message body.
///
/// UTF-8 String containing body of the message.
- void set_utf8_message(std::string &&data)
+ void set_utf8_message(utility::string &&data)
{
- this->set_message(concurrency::streams::container_buffer(std::move(data)));
+ this->set_message(concurrency::streams::container_buffer(std::move(data)));
}
///
/// Sets a UTF-8 message as the message body.
///
/// UTF-8 String containing body of the message.
- void set_utf8_message(const std::string &data)
+ void set_utf8_message(const utility::string &data)
{
- this->set_message(concurrency::streams::container_buffer(data));
+ this->set_message(concurrency::streams::container_buffer(data));
}
///
@@ -154,14 +154,14 @@ class websocket_outgoing_message
#if !defined(__cplusplus_winrt)
void set_message_pong()
{
- concurrency::streams::container_buffer buffer("");
+ concurrency::streams::container_buffer buffer("");
m_msg_type = websocket_message_type::pong;
m_length = static_cast(buffer.size());
m_body = buffer;
}
#endif
- void set_message(const concurrency::streams::container_buffer &buffer)
+ void set_message(const concurrency::streams::container_buffer &buffer)
{
m_msg_type = websocket_message_type::text_message;
m_length = static_cast(buffer.size());
@@ -188,7 +188,7 @@ class websocket_incoming_message
/// A body can only be extracted once because in some cases an optimization is made where the data is 'moved' out.
///
/// String containing body of the message.
- _ASYNCRTIMP pplx::task extract_string() const;
+ _ASYNCRTIMP pplx::task extract_string() const;
///
/// Produces a stream which the caller may use to retrieve body from an incoming message.
@@ -242,7 +242,7 @@ class websocket_incoming_message
// Store message body in a container buffer backed by a string.
// Allows for optimization in the string message cases.
- concurrency::streams::container_buffer m_body;
+ concurrency::streams::container_buffer m_body;
websocket_message_type m_msg_type;
};
diff --git a/Release/include/pplx/pplxtasks.h b/Release/include/pplx/pplxtasks.h
index e784306d40..923b328c46 100644
--- a/Release/include/pplx/pplxtasks.h
+++ b/Release/include/pplx/pplxtasks.h
@@ -117,13 +117,17 @@ namespace std
}
}
#endif /* _MSC_VER < 1700 */
-#ifndef _PPLTASK_ASYNC_LOGGING
- #if _MSC_VER >= 1800 && defined(__cplusplus_winrt)
- #define _PPLTASK_ASYNC_LOGGING 1 // Only enable async logging under dev12 winrt
- #else
- #define _PPLTASK_ASYNC_LOGGING 0
- #endif
-#endif /* !_PPLTASK_ASYNC_LOGGING */
+
+#ifndef _PPLTASK_ASYNC_LOGGING
+#define _PPLTASK_ASYNC_LOGGING 1
+#endif // #ifndef _PPLTASK_ASYNC_LOGGING
+
+#if _PPLTASK_ASYNC_LOGGING
+#pragma detect_mismatch("_PPLTASK_ASYNC_LOGGING", "1")
+#else
+#pragma detect_mismatch("_PPLTASK_ASYNC_LOGGING", "0")
+#endif // #if _PPLTASK_ASYNC_LOGGING
+
#endif /* _MSC_VER */
#pragma pack(push,_CRT_PACKING)
@@ -249,7 +253,7 @@ namespace details
// If _M_SingleFrame != nullptr, there will be only one frame of callstacks, which is stored in _M_SingleFrame;
// otherwise, _M_Frame will store all the callstack frames.
void* _M_SingleFrame;
- std::vector _M_frames;
+ utility::vector _M_frames;
public:
_TaskCreationCallstack()
{
@@ -857,9 +861,9 @@ namespace details
// The below are for composability with tasks auto-created from when_any / when_all / && / || constructs.
//
template
- struct _ResultHolder>
+ struct _ResultHolder>
{
- void Set(const std::vector<_Type^>& _type)
+ void Set(const utility::vector<_Type^>& _type)
{
_Result.reserve(_type.size());
@@ -869,10 +873,10 @@ namespace details
}
}
- std::vector<_Type^> Get()
+ utility::vector<_Type^> Get()
{
// Return vectory with the objects that are marshaled in the proper appartment
- std::vector<_Type^> _Return;
+ utility::vector<_Type^> _Return;
_Return.reserve(_Result.size());
for (auto _PTask = _Result.begin(); _PTask != _Result.end(); ++_PTask)
@@ -883,7 +887,7 @@ namespace details
return _Return;
}
- std::vector< ::Platform::Agile<_Type^> > _Result;
+ utility::vector< ::Platform::Agile<_Type^> > _Result;
};
template
@@ -1415,7 +1419,7 @@ namespace details
struct _Task_ptr
{
typedef std::shared_ptr<_Task_impl<_ReturnType>> _Type;
- static _Type _Make(_CancellationTokenState * _Ct, scheduler_ptr _Scheduler_arg) { return std::make_shared<_Task_impl<_ReturnType>>(_Ct, _Scheduler_arg); }
+ static _Type _Make(_CancellationTokenState * _Ct, scheduler_ptr _Scheduler_arg) { return utility::make_shared<_Task_impl<_ReturnType>>(_Ct, _Scheduler_arg); }
};
typedef _TaskCollection_t::_TaskProcHandle_t _UnrealizedChore_t;
@@ -1441,7 +1445,7 @@ namespace details
virtual ~_ContinuationTaskHandleBase() {}
};
-#if _PPLTASK_ASYNC_LOGGING
+#if _PPLTASK_ASYNC_LOGGING && _MSC_VER >= 1800 && defined(__cplusplus_winrt)
// GUID used for identifying causality logs from PPLTask
const ::Platform::Guid _PPLTaskCausalityPlatformID(0x7A76B220, 0xA758, 0x4E6E, 0xB0, 0xE0, 0xD7, 0xC6, 0xD7, 0x4A, 0x88, 0xFE);
@@ -1863,7 +1867,7 @@ namespace details
{
// This task was canceled because the task body encountered an exception.
_ASSERTE(!_HasUserException());
- return _CancelAndRunContinuations(true, true, false, std::make_shared<_ExceptionHolder>(_Exception, _GetTaskCreationCallstack()));
+ return _CancelAndRunContinuations(true, true, false, utility::make_shared<_ExceptionHolder>(_Exception, _GetTaskCreationCallstack()));
}
#endif /* defined (__cplusplus_winrt) */
@@ -1871,7 +1875,7 @@ namespace details
{
// This task was canceled because the task body encountered an exception.
_ASSERTE(!_HasUserException());
- return _CancelAndRunContinuations(true, true, false, std::make_shared<_ExceptionHolder>(_Exception, _GetTaskCreationCallstack()));
+ return _CancelAndRunContinuations(true, true, false, utility::make_shared<_ExceptionHolder>(_Exception, _GetTaskCreationCallstack()));
}
void _RegisterCancellation(std::weak_ptr<_Task_impl_base> _WeakPtr)
@@ -2360,7 +2364,7 @@ namespace details
_Task_impl_base const & operator=(_Task_impl_base const&);
};
-#if _PPLTASK_ASYNC_LOGGING
+#if _PPLTASK_ASYNC_LOGGING && _MSC_VER >= 1800 && defined(__cplusplus_winrt)
inline void _TaskEventLogger::_LogTaskCompleted()
{
if (_M_scheduled)
@@ -2587,7 +2591,7 @@ namespace details
public:
- typedef std::vector::_Type> _TaskList;
+ typedef utility::vector::_Type> _TaskList;
_Task_completion_event_impl() :
_M_fHasValue(false), _M_fIsCanceled(false)
@@ -2668,7 +2672,7 @@ class task_completion_event
///
/**/
task_completion_event()
- : _M_Impl(std::make_shared>())
+ : _M_Impl(utility::make_shared>())
{
}
@@ -2824,7 +2828,7 @@ class task_completion_event
static std::shared_ptr _ToExceptionHolder(std::exception_ptr _ExceptionPtr, const details::_TaskCreationCallstack &_SetExceptionAddressHint)
{
- return std::make_shared(_ExceptionPtr, _SetExceptionAddressHint);
+ return utility::make_shared(_ExceptionPtr, _SetExceptionAddressHint);
}
@@ -3093,7 +3097,7 @@ namespace details
typename std::enable_if,
typename std::decay<_Tx>::type>::value>::type>
explicit _NonCopyableFunctorWrapper(_Tx&& f)
- : _M_functor{std::make_shared<_Ty>(std::forward<_Tx>(f))}
+ : _M_functor{utility::make_shared<_Ty>(std::forward<_Tx>(f))}
{}
template
@@ -6280,14 +6284,14 @@ namespace details
}
task_completion_event<_Unit_type> _M_completed;
- _ResultHolder > _M_vector;
+ _ResultHolder > _M_vector;
_ResultHolder<_Type> _M_mergeVal;
atomic_size_t _M_completeCount;
size_t _M_numTasks;
};
template
- struct _RunAllParam >
+ struct _RunAllParam >
{
_RunAllParam() : _M_completeCount(0), _M_numTasks(0)
{
@@ -6304,7 +6308,7 @@ namespace details
}
task_completion_event<_Unit_type> _M_completed;
- std::vector<_ResultHolder > > _M_vector;
+ utility::vector<_ResultHolder > > _M_vector;
atomic_size_t _M_completeCount;
size_t _M_numTasks;
};
@@ -6375,7 +6379,7 @@ namespace details
template
struct _WhenAllImpl
{
- static task> _Perform(const task_options& _TaskOptions, _Iterator _Begin, _Iterator _End)
+ static task> _Perform(const task_options& _TaskOptions, _Iterator _Begin, _Iterator _End)
{
_CancellationTokenState *_PTokenState = _TaskOptions.has_cancellation_token() ? _TaskOptions.get_cancellation_token()._GetImplValue() : nullptr;
@@ -6387,7 +6391,7 @@ namespace details
_Options.set_cancellation_token(_MergedSource.get_token());
task<_Unit_type> _All_tasks_completed(_PParam->_M_completed, _Options);
// The return task must be created before step 3 to enforce inline execution.
- auto _ReturnTask = _All_tasks_completed._Then([=](_Unit_type) -> std::vector<_ElementType> {
+ auto _ReturnTask = _All_tasks_completed._Then([=](_Unit_type) -> utility::vector<_ElementType> {
return _PParam->_M_vector.Get();
}, nullptr);
@@ -6444,13 +6448,13 @@ namespace details
};
template
- struct _WhenAllImpl, _Iterator>
+ struct _WhenAllImpl, _Iterator>
{
- static task> _Perform(const task_options& _TaskOptions, _Iterator _Begin, _Iterator _End)
+ static task> _Perform(const task_options& _TaskOptions, _Iterator _Begin, _Iterator _End)
{
_CancellationTokenState *_PTokenState = _TaskOptions.has_cancellation_token() ? _TaskOptions.get_cancellation_token()._GetImplValue() : nullptr;
- auto _PParam = new _RunAllParam>();
+ auto _PParam = new _RunAllParam>();
cancellation_token_source _MergedSource;
// Step1: Create task completion event.
@@ -6458,12 +6462,12 @@ namespace details
_Options.set_cancellation_token(_MergedSource.get_token());
task<_Unit_type> _All_tasks_completed(_PParam->_M_completed, _Options);
// The return task must be created before step 3 to enforce inline execution.
- auto _ReturnTask = _All_tasks_completed._Then([=](_Unit_type) -> std::vector<_ElementType> {
+ auto _ReturnTask = _All_tasks_completed._Then([=](_Unit_type) -> utility::vector<_ElementType> {
_ASSERTE(_PParam->_M_completeCount == _PParam->_M_numTasks);
- std::vector<_ElementType> _Result;
+ utility::vector<_ElementType> _Result;
for(size_t _I = 0; _I < _PParam->_M_numTasks; _I++)
{
- const std::vector<_ElementType>& _Vec = _PParam->_M_vector[_I].Get();
+ const utility::vector<_ElementType>& _Vec = _PParam->_M_vector[_I].Get();
_Result.insert(_Result.end(), _Vec.begin(), _Vec.end());
}
return _Result;
@@ -6502,7 +6506,7 @@ namespace details
_ReturnTask._SetAsync();
}
- _PTask->_Then([_PParam, _Index](task> _ResultTask) {
+ _PTask->_Then([_PParam, _Index](task> _ResultTask) {
auto _PParamCopy = _PParam;
auto _IndexCopy = _Index;
@@ -6583,7 +6587,7 @@ namespace details
};
template
- task> _WhenAllVectorAndValue(const task>& _VectorTask, const task<_ReturnType>& _ValueTask,
+ task> _WhenAllVectorAndValue(const task>& _VectorTask, const task<_ReturnType>& _ValueTask,
bool _OutputVectorFirst)
{
auto _PParam = new _RunAllParam<_ReturnType>();
@@ -6592,7 +6596,7 @@ namespace details
// Step1: Create task completion event.
task<_Unit_type> _All_tasks_completed(_PParam->_M_completed, _MergedSource.get_token());
// The return task must be created before step 3 to enforce inline execution.
- auto _ReturnTask = _All_tasks_completed._Then([=](_Unit_type) -> std::vector<_ReturnType> {
+ auto _ReturnTask = _All_tasks_completed._Then([=](_Unit_type) -> utility::vector<_ReturnType> {
_ASSERTE(_PParam->_M_completeCount == 2);
auto _Result = _PParam->_M_vector.Get(); // copy by value
auto _mergeVal = _PParam->_M_mergeVal.Get();
@@ -6619,7 +6623,7 @@ namespace details
{
_ReturnTask._SetAsync();
}
- _VectorTask._Then([_PParam](task> _ResultTask) {
+ _VectorTask._Then([_PParam](task> _ResultTask) {
auto _PParamCopy = _PParam;
auto _Func = [_PParamCopy, &_ResultTask]() {
auto _ResultLocal = _ResultTask._GetImpl()->_GetResult();
@@ -6656,7 +6660,7 @@ namespace details
///
///
/// A task that completes sucessfully when all of the input tasks have completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output
+/// the output of this function will be a task<utility::vector<T>>. If the input tasks are of type void the output
/// task will also be a task<void>.
///
///
@@ -6687,10 +6691,10 @@ auto when_all(_Iterator _Begin, _Iterator _End, const task_options& _TaskOptions
///
///
/// A task that completes successfully when both of the input tasks have completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output
+/// the output of this function will be a task<utility::vector<T>>. If the input tasks are of type void the output
/// task will also be a task<void>.
/// To allow for a construct of the sort taskA && taskB && taskC, which are combined in pairs, the && operator
-/// produces a task<std::vector<T>> if either one or both of the tasks are of type task<std::vector<T>>.
+/// produces a task<utility::vector<T>> if either one or both of the tasks are of type task<utility::vector<T>>.
///
///
/// If one of the tasks is canceled or throws an exception, the returned task will complete early, in the canceled state, and the exception,
@@ -6719,10 +6723,10 @@ auto operator&&(const task<_ReturnType> & _Lhs, const task<_ReturnType> & _Rhs)
///
///
/// A task that completes successfully when both of the input tasks have completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output
+/// the output of this function will be a task<utility::vector<T>>. If the input tasks are of type void the output
/// task will also be a task<void>.
/// To allow for a construct of the sort taskA && taskB && taskC, which are combined in pairs, the && operator
-/// produces a task<std::vector<T>> if either one or both of the tasks are of type task<std::vector<T>>.
+/// produces a task<utility::vector<T>> if either one or both of the tasks are of type task<utility::vector<T>>.
///
///
/// If one of the tasks is canceled or throws an exception, the returned task will complete early, in the canceled state, and the exception,
@@ -6731,7 +6735,7 @@ auto operator&&(const task<_ReturnType> & _Lhs, const task<_ReturnType> & _Rhs)
///
/**/
template
-auto operator&&(const task> & _Lhs, const task<_ReturnType> & _Rhs) -> decltype(details::_WhenAllVectorAndValue(_Lhs, _Rhs, true))
+auto operator&&(const task> & _Lhs, const task<_ReturnType> & _Rhs) -> decltype(details::_WhenAllVectorAndValue(_Lhs, _Rhs, true))
{
return details::_WhenAllVectorAndValue(_Lhs, _Rhs, true);
}
@@ -6750,10 +6754,10 @@ auto operator&&(const task> & _Lhs, const task<_ReturnT
///
///
/// A task that completes successfully when both of the input tasks have completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output
+/// the output of this function will be a task<utility::vector<T>>. If the input tasks are of type void the output
/// task will also be a task<void>.
/// To allow for a construct of the sort taskA && taskB && taskC, which are combined in pairs, the && operator
-/// produces a task<std::vector<T>> if either one or both of the tasks are of type task<std::vector<T>>.
+/// produces a task<utility::vector<T>> if either one or both of the tasks are of type task<utility::vector<T>>.
///
///
/// If one of the tasks is canceled or throws an exception, the returned task will complete early, in the canceled state, and the exception,
@@ -6762,7 +6766,7 @@ auto operator&&(const task> & _Lhs, const task<_ReturnT
///
/**/
template
-auto operator&&(const task<_ReturnType> & _Lhs, const task> & _Rhs) -> decltype(details::_WhenAllVectorAndValue(_Rhs, _Lhs, false))
+auto operator&&(const task<_ReturnType> & _Lhs, const task> & _Rhs) -> decltype(details::_WhenAllVectorAndValue(_Rhs, _Lhs, false))
{
return details::_WhenAllVectorAndValue(_Rhs, _Lhs, false);
}
@@ -6781,10 +6785,10 @@ auto operator&&(const task<_ReturnType> & _Lhs, const task
///
/// A task that completes successfully when both of the input tasks have completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>>. If the input tasks are of type void the output
+/// the output of this function will be a task<utility::vector<T>>. If the input tasks are of type void the output
/// task will also be a task<void>.
/// To allow for a construct of the sort taskA && taskB && taskC, which are combined in pairs, the && operator
-/// produces a task<std::vector<T>> if either one or both of the tasks are of type task<std::vector<T>>.
+/// produces a task<utility::vector<T>> if either one or both of the tasks are of type task<utility::vector<T>>.
///
///
/// If one of the tasks is canceled or throws an exception, the returned task will complete early, in the canceled state, and the exception,
@@ -6793,9 +6797,9 @@ auto operator&&(const task<_ReturnType> & _Lhs, const task
/**/
template
-auto operator&&(const task> & _Lhs, const task> & _Rhs) -> decltype(when_all(&_Lhs, &_Lhs))
+auto operator&&(const task> & _Lhs, const task> & _Rhs) -> decltype(when_all(&_Lhs, &_Lhs))
{
- task> _PTasks[2] = {_Lhs, _Rhs};
+ task> _PTasks[2] = {_Lhs, _Rhs};
return when_all(_PTasks, _PTasks+2);
}
@@ -7071,10 +7075,10 @@ auto when_any(_Iterator _Begin, _Iterator _End, cancellation_token _Cancellation
///
///
/// A task that completes sucessfully when either of the input tasks has completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>. If the input tasks are of type void the output task
+/// the output of this function will be a task<utility::vector<T>. If the input tasks are of type void the output task
/// will also be a task<void>.
/// To allow for a construct of the sort taskA || taskB && taskC, which are combined in pairs, with && taking precedence
-/// over ||, the operator|| produces a task<std::vector<T>> if one of the tasks is of type task<std::vector<T>>
+/// over ||, the operator|| produces a task<utility::vector<T>> if one of the tasks is of type task<utility::vector<T>>
/// and the other one is of type task<T>.
///
///
@@ -7132,10 +7136,10 @@ task<_ReturnType> operator||(const task<_ReturnType> & _Lhs, const task<_ReturnT
///
///
/// A task that completes sucessfully when either of the input tasks has completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>. If the input tasks are of type void the output task
+/// the output of this function will be a task<utility::vector<T>. If the input tasks are of type void the output task
/// will also be a task<void>.
/// To allow for a construct of the sort taskA || taskB && taskC, which are combined in pairs, with && taking precedence
-/// over ||, the operator|| produces a task<std::vector<T>> if one of the tasks is of type task<std::vector<T>>
+/// over ||, the operator|| produces a task<utility::vector<T>> if one of the tasks is of type task<utility::vector<T>>
/// and the other one is of type task<T>.
///
///
@@ -7145,15 +7149,15 @@ task<_ReturnType> operator||(const task<_ReturnType> & _Lhs, const task<_ReturnT
///
/**/
template
-task> operator||(const task> & _Lhs, const task<_ReturnType> & _Rhs)
+task> operator||(const task> & _Lhs, const task<_ReturnType> & _Rhs)
{
- auto _PParam = new details::_RunAnyParam, details::_CancellationTokenState *>>();
+ auto _PParam = new details::_RunAnyParam, details::_CancellationTokenState *>>();
- task, details::_CancellationTokenState *>> _Any_tasks_completed(_PParam->_M_Completed, _PParam->_M_cancellationSource.get_token());
+ task, details::_CancellationTokenState *>> _Any_tasks_completed(_PParam->_M_Completed, _PParam->_M_cancellationSource.get_token());
// Chain the return continuation task here to ensure it will get inline execution when _M_Completed.set is called,
// So that _PParam can be used before it getting deleted.
- auto _ReturnTask = _Any_tasks_completed._Then([=](std::pair, details::_CancellationTokenState *> _Ret) -> std::vector<_ReturnType> {
+ auto _ReturnTask = _Any_tasks_completed._Then([=](std::pair, details::_CancellationTokenState *> _Ret) -> utility::vector<_ReturnType> {
_ASSERTE(_Ret.second);
_JoinAllTokens_Add(_PParam->_M_cancellationSource, _Ret.second);
return _Ret.first;
@@ -7165,7 +7169,7 @@ task> operator||(const task> &
}
_PParam->_M_numTasks = 2;
- _Lhs._Then([_PParam](task> _ResultTask) {
+ _Lhs._Then([_PParam](task> _ResultTask) {
// Dev10 compiler bug
auto _PParamCopy = _PParam;
auto _Func = [&_ResultTask, _PParamCopy]() {
@@ -7182,7 +7186,7 @@ task> operator||(const task> &
auto _Func = [&_ResultTask, _PParamCopy]() {
auto _Result = _ResultTask._GetImpl()->_GetResult();
- std::vector<_ReturnType> _Vec;
+ utility::vector<_ReturnType> _Vec;
_Vec.push_back(_Result);
_PParamCopy->_M_Completed.set(std::make_pair(_Vec, _ResultTask._GetImpl()->_M_pTokenState));
};
@@ -7206,10 +7210,10 @@ task> operator||(const task> &
///
///
/// A task that completes sucessfully when either of the input tasks has completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>. If the input tasks are of type void the output task
+/// the output of this function will be a task<utility::vector<T>. If the input tasks are of type void the output task
/// will also be a task<void>.
/// To allow for a construct of the sort taskA || taskB && taskC, which are combined in pairs, with && taking precedence
-/// over ||, the operator|| produces a task<std::vector<T>> if one of the tasks is of type task<std::vector<T>>
+/// over ||, the operator|| produces a task<utility::vector<T>> if one of the tasks is of type task<utility::vector<T>>
/// and the other one is of type task<T>.
///
///
@@ -7219,7 +7223,7 @@ task> operator||(const task> &
///
/**/
template
-auto operator||(const task<_ReturnType> & _Lhs, const task> & _Rhs) -> decltype(_Rhs || _Lhs)
+auto operator||(const task<_ReturnType> & _Lhs, const task> & _Rhs) -> decltype(_Rhs || _Lhs)
{
return _Rhs || _Lhs;
}
@@ -7238,10 +7242,10 @@ auto operator||(const task<_ReturnType> & _Lhs, const task
///
/// A task that completes sucessfully when either of the input tasks has completed successfully. If the input tasks are of type T,
-/// the output of this function will be a task<std::vector<T>. If the input tasks are of type void the output task
+/// the output of this function will be a task<utility::vector<T>. If the input tasks are of type void the output task
/// will also be a task<void>.
/// To allow for a construct of the sort taskA || taskB && taskC, which are combined in pairs, with && taking precedence
-/// over ||, the operator|| produces a task<std::vector<T>> if one of the tasks is of type task<std::vector<T>>
+/// over ||, the operator|| produces a task<utility::vector<T>> if one of the tasks is of type task<utility::vector<T>>
/// and the other one is of type task<T>.
///
///
diff --git a/Release/src/http/client/http_client.cpp b/Release/src/http/client/http_client.cpp
index 2963fae3c2..35b7515ad8 100644
--- a/Release/src/http/client/http_client.cpp
+++ b/Release/src/http/client/http_client.cpp
@@ -58,13 +58,13 @@ void request_context::complete_request(utility::size64_t body_size)
finish();
}
-void request_context::report_error(unsigned long error_code, const std::string &errorMessage)
+void request_context::report_error(unsigned long error_code, const utility::string &errorMessage)
{
report_exception(http_exception(static_cast(error_code), errorMessage));
}
#if defined(_WIN32)
-void request_context::report_error(unsigned long error_code, const std::wstring &errorMessage)
+void request_context::report_error(unsigned long error_code, const utility::wstring &errorMessage)
{
report_exception(http_exception(static_cast(error_code), errorMessage));
}
@@ -109,7 +109,7 @@ bool request_context::handle_content_encoding_compression()
if (alg != web::http::details::compression::compression_algorithm::invalid)
{
- m_decompressor = utility::details::make_unique(alg);
+ m_decompressor = utility::make_unique(alg);
}
else
{
@@ -315,7 +315,7 @@ class http_pipeline
private:
// The vector of pipeline stages.
- std::vector> m_stages;
+ utility::vector> m_stages;
pplx::extensibility::recursive_lock_t m_lock;
};
@@ -338,7 +338,7 @@ void http_client::add_handler(const std::function __cd
std::function(http_request, std::shared_ptr)> m_handler;
};
- m_pipeline->append(std::make_shared(handler));
+ m_pipeline->append(utility::make_shared(handler));
}
void http_client::add_handler(const std::shared_ptr &stage)
@@ -367,15 +367,15 @@ http_client::http_client(const uri &base_uri, const http_client_config &client_c
final_pipeline_stage = details::create_platform_final_pipeline_stage(uri(base_uri), http_client_config(client_config));
}
- m_pipeline = std::make_shared(std::move(final_pipeline_stage));
+ m_pipeline = utility::make_shared(std::move(final_pipeline_stage));
#if !defined(CPPREST_TARGET_XP)
add_handler(std::static_pointer_cast(
- std::make_shared(client_config.oauth1())));
+ utility::make_shared(client_config.oauth1())));
#endif
add_handler(std::static_pointer_cast(
- std::make_shared(client_config.oauth2())));
+ utility::make_shared(client_config.oauth2())));
}
http_client::~http_client() CPPREST_NOEXCEPT {}
diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp
index e3ea15c9ff..eb3a5bb87d 100644
--- a/Release/src/http/client/http_client_asio.cpp
+++ b/Release/src/http/client/http_client_asio.cpp
@@ -131,14 +131,6 @@ enum class httpclient_errorcode_context
close
};
-static std::string generate_base64_userpass(const ::web::credentials& creds)
-{
- auto userpass = creds.username() + U(":") + *creds._internal_decrypt();
- auto&& u8_userpass = utility::conversions::to_utf8string(userpass);
- std::vector credentials_buffer(u8_userpass.begin(), u8_userpass.end());
- return utility::conversions::to_utf8string(utility::conversions::to_base64(credentials_buffer));
-}
-
class asio_connection_pool;
class asio_connection
@@ -172,7 +164,7 @@ class asio_connection
{
ssl_context_callback(ssl_context);
}
- m_ssl_stream = utility::details::make_unique>(
+ m_ssl_stream = utility::make_unique>(
m_socket, ssl_context);
m_cn_hostname = std::move(cn_hostname);
}
@@ -336,7 +328,7 @@ class asio_connection
// as normal message processing.
std::mutex m_socket_lock;
tcp::socket m_socket;
- std::unique_ptr> m_ssl_stream;
+ utility::unique_ptr> m_ssl_stream;
std::string m_cn_hostname;
bool m_is_reused;
@@ -383,7 +375,7 @@ class connection_pool_stack
private:
size_t m_highWater = 0;
- std::vector> m_connections;
+ utility::vector> m_connections;
};
/// Implements a connection pool with adaptive connection removal
@@ -511,7 +503,7 @@ class asio_client final : public _http_client_communicator
asio_client(http::uri&& address, http_client_config&& client_config)
: _http_client_communicator(std::move(address), std::move(client_config))
, m_resolver(crossplat::threadpool::shared_instance().service())
- , m_pool(std::make_shared())
+ , m_pool(utility::make_shared())
, m_start_with_ssl(base_uri().scheme() == U("https") && !this->client_config().proxy().is_specified())
{
}
@@ -527,7 +519,7 @@ class asio_client final : public _http_client_communicator
if (conn == nullptr)
{
// Pool was empty. Create a new connection
- conn = std::make_shared(crossplat::threadpool::shared_instance().service());
+ conn = utility::make_shared(crossplat::threadpool::shared_instance().service());
if (m_start_with_ssl)
{
conn->upgrade_to_ssl(std::move(cn_host), this->client_config().get_ssl_context_callback());
@@ -579,7 +571,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
{
auto client_cast(std::static_pointer_cast(client));
auto connection(client_cast->obtain_connection(request));
- auto ctx = std::make_shared(client, request, connection);
+ auto ctx = utility::make_shared(client, request, connection);
ctx->m_timer.set_ctx(std::weak_ptr(ctx));
return ctx;
}
@@ -939,7 +931,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
// The ssl_tunnel_proxy keeps the context alive and then calls back once the ssl tunnel is established via
// 'start_http_request_flow'
std::shared_ptr ssl_tunnel =
- std::make_shared(shared_from_this(), start_http_request_flow);
+ utility::make_shared(shared_from_this(), start_http_request_flow);
ssl_tunnel->start_proxy_connect();
}
else
@@ -973,7 +965,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
{
std::string header;
header.append("Authorization: Basic ");
- header.append(generate_base64_userpass(m_http_client->client_config().credentials()));
+ header.append(m_http_client->client_config().credentials().to_base64());
header.append(CRLF);
return header;
}
@@ -982,7 +974,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
{
std::string header;
header.append("Proxy-Authorization: Basic ");
- header.append(generate_base64_userpass(m_http_client->client_config().proxy().credentials()));
+ header.append(m_http_client->client_config().proxy().credentials().to_base64());
header.append(CRLF);
return header;
}
@@ -1575,7 +1567,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
// Move the decompressed buffer into a shared_ptr to keep it alive until putn_nocopy completes.
// When VS 2013 support is dropped, this should be changed to a unique_ptr plus a move capture.
using web::http::details::compression::data_buffer;
- auto shared_decompressed = std::make_shared(std::move(decompressed));
+ auto shared_decompressed = utility::make_shared(std::move(decompressed));
writeBuffer.putn_nocopy(shared_decompressed->data(), shared_decompressed->size())
.then([this_request, to_read, shared_decompressed AND_CAPTURE_MEMBER_FUNCTION_POINTERS](
@@ -1705,7 +1697,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
// Move the decompressed buffer into a shared_ptr to keep it alive until putn_nocopy completes.
// When VS 2013 support is dropped, this should be changed to a unique_ptr plus a move capture.
using web::http::details::compression::data_buffer;
- auto shared_decompressed = std::make_shared(std::move(decompressed));
+ auto shared_decompressed = utility::make_shared(std::move(decompressed));
writeBuffer.putn_nocopy(shared_decompressed->data(), shared_decompressed->size())
.then([this_request, read_size, shared_decompressed AND_CAPTURE_MEMBER_FUNCTION_POINTERS](
@@ -1862,7 +1854,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
std::shared_ptr<_http_client_communicator> create_platform_final_pipeline_stage(uri&& base_uri,
http_client_config&& client_config)
{
- return std::make_shared(std::move(base_uri), std::move(client_config));
+ return utility::make_shared(std::move(base_uri), std::move(client_config));
}
void asio_client::send_request(const std::shared_ptr& request_ctx)
diff --git a/Release/src/http/client/http_client_impl.h b/Release/src/http/client/http_client_impl.h
index 7b6c974a0d..fed7b2040c 100644
--- a/Release/src/http/client/http_client_impl.h
+++ b/Release/src/http/client/http_client_impl.h
@@ -58,10 +58,10 @@ class request_context
///
void complete_request(utility::size64_t body_size);
- void report_error(unsigned long error_code, const std::string &errorMessage);
+ void report_error(unsigned long error_code, const utility::string &errorMessage);
#ifdef _WIN32
- void report_error(unsigned long error_code, const std::wstring &errorMessage);
+ void report_error(unsigned long error_code, const utility::wstring &errorMessage);
#endif
template
@@ -95,7 +95,7 @@ class request_context
// Registration for cancellation notification if enabled.
pplx::cancellation_token_registration m_cancellationRegistration;
- std::unique_ptr m_decompressor;
+ utility::unique_ptr m_decompressor;
protected:
@@ -141,7 +141,7 @@ class _http_client_communicator : public http_pipeline_stage
void async_send_request_impl(const std::shared_ptr &request);
// Queue used to guarantee ordering of requests, when applicable.
- std::queue> m_requests_queue;
+ utility::queue> m_requests_queue;
bool m_outstanding;
};
diff --git a/Release/src/http/client/http_client_winhttp.cpp b/Release/src/http/client/http_client_winhttp.cpp
index a1f69ab215..17daad8368 100644
--- a/Release/src/http/client/http_client_winhttp.cpp
+++ b/Release/src/http/client/http_client_winhttp.cpp
@@ -50,9 +50,9 @@ CPPREST_CONSTEXPR security_failure_message g_security_failure_messages[] = {
"WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR internal error."},
};
-std::string generate_security_failure_message(std::uint32_t flags)
+utility::string generate_security_failure_message(std::uint32_t flags)
{
- std::string result("SSL Error:");
+ utility::string result("SSL Error:");
for (const auto& message : g_security_failure_messages) {
if (flags & message.flag) {
result.push_back(' ');
@@ -148,18 +148,18 @@ static void parse_winhttp_headers(HINTERNET request_handle, _In_z_ utf16char *he
}
// Helper function to build error messages.
-static std::string build_error_msg(unsigned long code, const std::string &location)
+static utility::string build_error_msg(unsigned long code, const utility::string &location)
{
- std::string msg(location);
+ utility::string msg(location);
msg.append(": ");
- msg.append(std::to_string(code));
+ msg.append(utility::conversions::details::to_string(code));
msg.append(": ");
- msg.append(utility::details::windows_category().message(code));
+ msg.append(utility::details::windows_category().message(code).c_str());
return msg;
}
// Helper function to build an error message from a WinHTTP async result.
-static std::string build_error_msg(_In_ WINHTTP_ASYNC_RESULT *error_result)
+static utility::string build_error_msg(_In_ WINHTTP_ASYNC_RESULT *error_result)
{
switch(error_result->dwResult)
{
@@ -181,7 +181,7 @@ static std::string build_error_msg(_In_ WINHTTP_ASYNC_RESULT *error_result)
class memory_holder
{
uint8_t* m_externalData;
- std::vector m_internalData;
+ utility::vector m_internalData;
public:
memory_holder() : m_externalData(nullptr)
@@ -225,12 +225,19 @@ enum msg_body_type
// Additional information necessary to track a WinHTTP request.
class winhttp_request_context final : public request_context
{
+private:
+
+ struct private_constructor_cookie { };
+
public:
+ explicit winhttp_request_context(private_constructor_cookie, const std::shared_ptr<_http_client_communicator> &client, const http_request &request)
+ : winhttp_request_context(client, request) { };
+
// Factory function to create requests on the heap.
static std::shared_ptr create_request_context(const std::shared_ptr<_http_client_communicator> &client, const http_request &request)
{
- std::shared_ptr ret(new winhttp_request_context(client, request));
+ std::shared_ptr ret = utility::make_shared(private_constructor_cookie(), client, request);
ret->m_self_reference = ret;
return std::move(ret);
}
@@ -276,7 +283,7 @@ class winhttp_request_context final : public request_context
// If the user specified that to guarantee data buffering of request data, in case of challenged authentication requests, etc...
// Then if the request stream buffer doesn't support seeking we need to copy the body chunks as it is sent.
concurrency::streams::istream m_readStream;
- std::unique_ptr>> m_readBufferCopy;
+ utility::unique_ptr>> m_readBufferCopy;
virtual concurrency::streams::streambuf _get_readbuffer()
{
return m_readStream.streambuf();
@@ -427,7 +434,7 @@ class winhttp_request_context final : public request_context
private:
utility::string_t m_customCnCheck;
- std::vector m_cachedEncodedCert;
+ utility::vector m_cachedEncodedCert;
// Can only create on the heap using factory function.
winhttp_request_context(const std::shared_ptr<_http_client_communicator> &client, const http_request &request)
@@ -657,7 +664,7 @@ class winhttp_client final : public _http_client_communicator
if (uri.port() > 0)
{
proxy_str.push_back(_XPLATSTR(':'));
- proxy_str.append(::utility::conversions::details::to_string_t(uri.port()));
+ proxy_str.append(utility::conversions::details::to_string_t(uri.port()));
}
proxy_name = proxy_str.c_str();
@@ -968,7 +975,7 @@ class winhttp_client final : public _http_client_communicator
// Only need to cache the request body if user specified and the request stream doesn't support seeking.
if (winhttp_context->m_bodyType != no_body && client_config().buffer_request() && !winhttp_context->_get_readbuffer().can_seek())
{
- winhttp_context->m_readBufferCopy = ::utility::details::make_unique<::concurrency::streams::container_buffer>>();
+ winhttp_context->m_readBufferCopy = utility::make_unique<::concurrency::streams::container_buffer>>();
}
_start_request_send(winhttp_context, content_length);
@@ -981,10 +988,10 @@ class winhttp_client final : public _http_client_communicator
void _start_request_send(const std::shared_ptr& winhttp_context, size_t content_length)
{
// WinHttp takes a context object as a void*. We therefore heap allocate a std::weak_ptr to the request context which will be destroyed during the final callback.
- std::unique_ptr> weak_context_holder;
+ utility::unique_ptr> weak_context_holder;
if (winhttp_context->m_request_context == nullptr)
{
- weak_context_holder = std::make_unique>(winhttp_context);
+ weak_context_holder = utility::make_unique>(winhttp_context);
winhttp_context->m_request_context = weak_context_holder.get();
}
@@ -1122,7 +1129,7 @@ class winhttp_client final : public _http_client_communicator
if (p_request_context->m_readBufferCopy)
{
// Move the saved buffer into the read buffer, which now supports seeking.
- p_request_context->m_readStream = concurrency::streams::container_stream>::open_istream(std::move(p_request_context->m_readBufferCopy->collection()));
+ p_request_context->m_readStream = concurrency::streams::container_stream>::open_istream(std::move(p_request_context->m_readBufferCopy->collection()));
p_request_context->m_readBufferCopy.reset();
}
}
@@ -1331,13 +1338,12 @@ class winhttp_client final : public _http_client_communicator
// New scope to ensure plaintext password is cleared as soon as possible.
{
- auto password = cred._internal_decrypt();
if (!WinHttpSetCredentials(
hRequestHandle,
dwAuthTarget,
dwSelectedScheme,
cred.username().c_str(),
- password->c_str(),
+ cred._internal_decrypt()->c_str(),
nullptr))
{
return false;
@@ -1397,11 +1403,16 @@ class winhttp_client final : public _http_client_communicator
{
// This callback is responsible for freeing the type-erased context.
// This particular status code indicates that this is the final callback call, suitable for context destruction.
- delete p_weak_request_context;
+ auto lock = p_weak_request_context->lock();
+ if (lock) {
+ lock->cleanup();
+ } else {
+ utility::unique_ptr> weak_context_holder(p_weak_request_context);
+ }
return;
}
- auto p_request_context = p_weak_request_context->lock();
+ std::shared_ptr p_request_context = p_weak_request_context->lock();
if (!p_request_context)
{
// The request context was already released, probably due to cancellation
@@ -1470,7 +1481,7 @@ class winhttp_client final : public _http_client_communicator
return;
case WINHTTP_CALLBACK_STATUS_SECURE_FAILURE:
p_request_context->report_exception(web::http::http_exception(
- generate_security_failure_message(*reinterpret_cast(statusInfo))));
+ generate_security_failure_message(*reinterpret_cast(statusInfo)).c_str()));
return;
case WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE :
{
@@ -1521,7 +1532,7 @@ class winhttp_client final : public _http_client_communicator
query_header_length(hRequestHandle, WINHTTP_QUERY_RAW_HEADERS_CRLF, headerBufferLength);
// Now allocate buffer for headers and query for them.
- std::vector header_raw_buffer;
+ utility::vector header_raw_buffer;
header_raw_buffer.resize(headerBufferLength);
utf16char * header_buffer = reinterpret_cast(&header_raw_buffer[0]);
if(!WinHttpQueryHeaders(
@@ -1730,7 +1741,7 @@ class winhttp_client final : public _http_client_communicator
std::shared_ptr<_http_client_communicator> create_platform_final_pipeline_stage(uri&& base_uri, http_client_config&& client_config)
{
- return std::make_shared(std::move(base_uri), std::move(client_config));
+ return utility::make_shared(std::move(base_uri), std::move(client_config));
}
}}}}
diff --git a/Release/src/http/client/http_client_winrt.cpp b/Release/src/http/client/http_client_winrt.cpp
index 5a0697b489..2adbb2a282 100644
--- a/Release/src/http/client/http_client_winrt.cpp
+++ b/Release/src/http/client/http_client_winrt.cpp
@@ -45,7 +45,7 @@ class winrt_request_context final : public request_context
// Factory function to create requests on the heap.
static std::shared_ptr create_request_context(const std::shared_ptr<_http_client_communicator> &client, http_request &request)
{
- return std::make_shared(client, request);
+ return utility::make_shared(client, request);
}
Microsoft::WRL::ComPtr m_hRequest;
@@ -157,7 +157,7 @@ class HttpRequestCallback final :
{
if (m_request->m_exceptionPtr == nullptr)
{
- std::wstring msg(L"IXMLHttpRequest2Callback::OnError: ");
+ utility::wstring msg(L"IXMLHttpRequest2Callback::OnError: ");
msg.append(std::to_wstring(hrError));
msg.append(L": ");
msg.append(utility::conversions::to_string_t(utility::details::windows_category().message(hrError)));
@@ -553,7 +553,7 @@ class winrt_client final : public _http_client_communicator
std::shared_ptr<_http_client_communicator> create_platform_final_pipeline_stage(uri&& base_uri, http_client_config&& client_config)
{
- return std::make_shared(std::move(base_uri), std::move(client_config));
+ return utility::make_shared(std::move(base_uri), std::move(client_config));
}
}}}}
diff --git a/Release/src/http/client/x509_cert_utilities.cpp b/Release/src/http/client/x509_cert_utilities.cpp
index 0a7a762d50..8aa1861ef8 100644
--- a/Release/src/http/client/x509_cert_utilities.cpp
+++ b/Release/src/http/client/x509_cert_utilities.cpp
@@ -40,9 +40,9 @@ namespace client
{
namespace details
{
-static bool verify_X509_cert_chain(const std::vector& certChain, const std::string& hostName);
+static bool verify_X509_cert_chain(const utility::vector& certChain, const utility::string& hostName);
-bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verifyCtx, const std::string& hostName)
+bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verifyCtx, const utility::string& hostName)
{
X509_STORE_CTX* storeContext = verifyCtx.native_handle();
int currentDepth = X509_STORE_CTX_get_error_depth(storeContext);
@@ -58,7 +58,7 @@ bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verif
return false;
}
- std::vector certChain;
+ utility::vector certChain;
certChain.reserve(numCerts);
for (int i = 0; i < numCerts; ++i)
{
@@ -71,7 +71,7 @@ bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verif
return false;
}
- std::string certData;
+ utility::string certData;
certData.resize(len);
unsigned char* buffer = reinterpret_cast(&certData[0]);
len = i2d_X509(cert, &buffer);
@@ -89,7 +89,7 @@ bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verif
#if defined(_WIN32)
if (verify_result)
{
- boost::asio::ssl::rfc2818_verification rfc2818(hostName);
+ boost::asio::ssl::rfc2818_verification rfc2818(hostName.c_str());
verify_result = rfc2818(verify_result, verifyCtx);
}
#endif
@@ -140,7 +140,7 @@ static bool jni_failed(JNIEnv* env, const jmethodID& result)
#define CHECK_JNI(env) \
if (jni_failed(env)) return false;
-bool verify_X509_cert_chain(const std::vector& certChain, const std::string& hostName)
+bool verify_X509_cert_chain(const utility::vector& certChain, const utility::string& hostName)
{
JNIEnv* env = get_jvm_env();
@@ -310,12 +310,12 @@ class cf_ref
};
}
-bool verify_X509_cert_chain(const std::vector& certChain, const std::string& hostName)
+bool verify_X509_cert_chain(const utility::vector& certChain, const utility::string& hostName)
{
// Build up CFArrayRef with all the certificates.
// All this code is basically just to get into the correct structures for the Apple APIs.
// Copies are avoided whenever possible.
- std::vector> certs;
+ utility::vector> certs;
for (const auto& certBuf : certChain)
{
cf_ref certDataRef =
@@ -370,7 +370,7 @@ bool verify_X509_cert_chain(const std::vector& certChain, const std
#endif
#if defined(_WIN32)
-bool verify_X509_cert_chain(const std::vector& certChain, const std::string& hostname)
+bool verify_X509_cert_chain(const utility::vector& certChain, const utility::string& hostname)
{
// Create certificate context from server certificate.
winhttp_cert_context cert;
diff --git a/Release/src/http/common/http_helpers.cpp b/Release/src/http/common/http_helpers.cpp
index 2c45e5961d..11e0995e04 100644
--- a/Release/src/http/common/http_helpers.cpp
+++ b/Release/src/http/common/http_helpers.cpp
@@ -386,7 +386,7 @@ namespace compression
}
stream_decompressor::stream_decompressor(compression_algorithm alg)
- : m_pimpl(std::make_shared(alg))
+ : m_pimpl(utility::make_shared(alg))
{
}
@@ -420,7 +420,7 @@ namespace compression
}
stream_compressor::stream_compressor(compression_algorithm alg)
- : m_pimpl(std::make_shared(alg))
+ : m_pimpl(utility::make_shared(alg))
{
}
diff --git a/Release/src/http/common/http_msg.cpp b/Release/src/http/common/http_msg.cpp
index 8f218cb913..b9a1b6e1d4 100644
--- a/Release/src/http/common/http_msg.cpp
+++ b/Release/src/http/common/http_msg.cpp
@@ -65,7 +65,7 @@ namespace {
return unknown;
}
- std::string convert_utf16le_to_utf8(utf16string src, bool erase_bom)
+ utility::string convert_utf16le_to_utf8(utf16string src, bool erase_bom)
{
if (erase_bom && !src.empty())
{
@@ -110,7 +110,7 @@ namespace {
return src;
}
- std::string convert_utf16be_to_utf8(utf16string src, bool erase_bom)
+ utility::string convert_utf16be_to_utf8(utf16string src, bool erase_bom)
{
return utf16_to_utf8(big_endian_to_little_endian(std::move(src), erase_bom));
}
@@ -129,7 +129,7 @@ namespace {
#endif
}
- std::string convert_utf16_to_utf8(utf16string src)
+ utility::string convert_utf16_to_utf8(utf16string src)
{
const endianness endian = check_byte_order_mark(src);
switch (endian)
@@ -251,12 +251,12 @@ void parse_headers_string(_Inout_z_ utf16char *headersStr, http_headers &headers
}
-http_version __cdecl http_version::from_string(const std::string& http_version_string)
+http_version __cdecl http_version::from_string(const utility::string& http_version_string)
{
- std::stringstream str(http_version_string);
+ utility::stringstream str(http_version_string);
str.imbue(std::locale::classic());
- std::string http; std::getline(str, http, '/');
+ utility::string http; std::getline(str, http, '/');
unsigned int major = 0; str >> major;
char dot = '\0'; str >> dot;
unsigned int minor = 0; str >> minor;
@@ -269,14 +269,14 @@ http_version __cdecl http_version::from_string(const std::string& http_version_s
return{ 0, 0 };
}
-std::string http_version::to_utf8string() const
+utility::string http_version::to_utf8string() const
{
- std::string ret;
+ utility::string ret;
ret.reserve(8);
ret.append("HTTP/");
- ret.append(std::to_string(static_cast(major)));
+ ret.append(utility::conversions::details::to_string(static_cast(major)));
ret.append(".");
- ret.append(std::to_string(static_cast(minor)));
+ ret.append(utility::conversions::details::to_string(static_cast(minor)));
return ret;
}
@@ -610,8 +610,8 @@ utf8string details::http_msg_base::extract_utf8string(bool ignore_content_type)
|| utility::details::str_iequal(charset, charset_types::usascii)
|| utility::details::str_iequal(charset, charset_types::ascii))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return body;
}
@@ -619,8 +619,8 @@ utf8string details::http_msg_base::extract_utf8string(bool ignore_content_type)
// Latin1
else if (utility::details::str_iequal(charset, charset_types::latin1))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return latin1_to_utf8(std::move(body));
}
@@ -681,8 +681,8 @@ utf16string details::http_msg_base::extract_utf16string(bool ignore_content_type
|| utility::details::str_iequal(charset, charset_types::usascii)
|| utility::details::str_iequal(charset, charset_types::ascii))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return utility::conversions::utf8_to_utf16(std::move(body));
}
@@ -690,8 +690,8 @@ utf16string details::http_msg_base::extract_utf16string(bool ignore_content_type
// Latin1
else if (utility::details::str_iequal(charset, charset_types::latin1))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return latin1_to_utf16(std::move(body));
}
@@ -733,8 +733,8 @@ utility::string_t details::http_msg_base::extract_string(bool ignore_content_typ
if (utility::details::str_iequal(charset, charset_types::usascii)
|| utility::details::str_iequal(charset, charset_types::ascii))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return to_string_t(std::move(body));
}
@@ -742,8 +742,8 @@ utility::string_t details::http_msg_base::extract_string(bool ignore_content_typ
// Latin1
if(utility::details::str_iequal(charset, charset_types::latin1))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
// Could optimize for linux in the future if a latin1_to_utf8 function was written.
return to_string_t(latin1_to_utf16(std::move(body)));
@@ -752,8 +752,8 @@ utility::string_t details::http_msg_base::extract_string(bool ignore_content_typ
// utf-8.
else if(utility::details::str_iequal(charset, charset_types::utf8))
{
- std::string body;
- body.resize((std::string::size_type)buf_r.in_avail());
+ utility::string body;
+ body.resize((utility::string::size_type)buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return to_string_t(std::move(body));
}
@@ -803,7 +803,7 @@ json::value details::http_msg_base::_extract_json(bool ignore_content_type)
// Latin1
if(utility::details::str_iequal(charset, charset_types::latin1))
{
- std::string body;
+ utility::string body;
body.resize(buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
// On Linux could optimize in the future if a latin1_to_utf8 function is written.
@@ -815,7 +815,7 @@ json::value details::http_msg_base::_extract_json(bool ignore_content_type)
|| utility::details::str_iequal(charset, charset_types::usascii)
|| utility::details::str_iequal(charset, charset_types::ascii))
{
- std::string body;
+ utility::string body;
body.resize(buf_r.in_avail());
buf_r.getn(const_cast(reinterpret_cast(body.data())), body.size()).get(); // There is no risk of blocking.
return json::value::parse(to_string_t(std::move(body)));
@@ -854,14 +854,14 @@ json::value details::http_msg_base::_extract_json(bool ignore_content_type)
}
}
-std::vector details::http_msg_base::_extract_vector()
+utility::vector details::http_msg_base::_extract_vector()
{
if (!instream())
{
throw http_exception(stream_was_set_explicitly);
}
- std::vector body;
+ utility::vector body;
auto buf_r = instream().streambuf();
const size_t size = buf_r.in_avail();
body.resize(size);
@@ -897,7 +897,7 @@ static utility::string_t convert_body_to_string_t(const utility::string_t &conte
// Latin1
if(utility::details::str_iequal(charset, charset_types::latin1))
{
- std::string body;
+ utility::string body;
body.resize(streambuf.in_avail());
if(streambuf.scopy((unsigned char *)&body[0], body.size()) == 0) return string_t();
return to_string_t(latin1_to_utf16(std::move(body)));
@@ -906,7 +906,7 @@ static utility::string_t convert_body_to_string_t(const utility::string_t &conte
// utf-8.
else if(utility::details::str_iequal(charset, charset_types::utf8))
{
- std::string body;
+ utility::string body;
body.resize(streambuf.in_avail());
if(streambuf.scopy((unsigned char *)&body[0], body.size()) == 0) return string_t();
return to_string_t(std::move(body));
@@ -1033,7 +1033,7 @@ details::_http_request::_http_request(http::method mtd)
}
}
-details::_http_request::_http_request(std::unique_ptr server_context)
+details::_http_request::_http_request(utility::unique_ptr server_context)
: m_initiated_response(0),
m_server_context(std::move(server_context)),
m_cancellationToken(pplx::cancellation_token::none()),
diff --git a/Release/src/http/common/internal_http_helpers.h b/Release/src/http/common/internal_http_helpers.h
index 024ac84ac4..232f7cf68c 100644
--- a/Release/src/http/common/internal_http_helpers.h
+++ b/Release/src/http/common/internal_http_helpers.h
@@ -17,7 +17,7 @@ utility::string_t get_default_reason_phrase(status_code code);
// simple helper functions to trim whitespace.
template
-void trim_whitespace(std::basic_string &str)
+void trim_whitespace(utility::basic_string &str)
{
size_t index;
// trim left whitespace
diff --git a/Release/src/http/common/x509_cert_utilities.h b/Release/src/http/common/x509_cert_utilities.h
index 9884b05993..3b3a85587b 100644
--- a/Release/src/http/common/x509_cert_utilities.h
+++ b/Release/src/http/common/x509_cert_utilities.h
@@ -101,7 +101,7 @@ namespace details
/// Boost.ASIO context to get certificate chain from.
/// Host name from the URI.
/// True if verification passed and server can be trusted, false otherwise.
-bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verifyCtx, const std::string& hostName);
+bool verify_cert_chain_platform_specific(boost::asio::ssl::verify_context& verifyCtx, const utility::string& hostName);
}
}
}
diff --git a/Release/src/http/listener/http_listener.cpp b/Release/src/http/listener/http_listener.cpp
index baa204b56d..423adfe00b 100644
--- a/Release/src/http/listener/http_listener.cpp
+++ b/Release/src/http/listener/http_listener.cpp
@@ -63,21 +63,6 @@ details::http_listener_impl::http_listener_impl(http::uri address, http_listener
check_listener_uri(m_uri);
}
-http_listener::~http_listener()
-{
- if(m_impl)
- {
- // As a safe guard close the listener if not already done.
- // Users are required to call close, but this is just a safeguard.
- try
- {
- close().wait();
- } catch(...)
- {
- }
- }
-}
-
pplx::task details::http_listener_impl::open()
{
// Do nothing if the open operation was already attempted
diff --git a/Release/src/http/listener/http_server_api.cpp b/Release/src/http/listener/http_server_api.cpp
index 9a8289b7fa..29e5913925 100644
--- a/Release/src/http/listener/http_server_api.cpp
+++ b/Release/src/http/listener/http_server_api.cpp
@@ -26,7 +26,7 @@ namespace details
pplx::extensibility::critical_section_t http_server_api::s_lock;
-std::unique_ptr http_server_api::s_server_api((http_server*)nullptr);
+utility::unique_ptr http_server_api::s_server_api((http_server*)nullptr);
pplx::details::atomic_long http_server_api::s_registrations(0L);
@@ -35,7 +35,7 @@ bool http_server_api::has_listener()
return s_registrations > 0L;
}
-void http_server_api::register_server_api(std::unique_ptr server_api)
+void http_server_api::register_server_api(utility::unique_ptr server_api)
{
pplx::extensibility::scoped_critical_section_t lock(s_lock);
http_server_api::unsafe_register_server_api(std::move(server_api));
@@ -53,7 +53,7 @@ void http_server_api::unregister_server_api()
s_server_api.release();
}
-void http_server_api::unsafe_register_server_api(std::unique_ptr server_api)
+void http_server_api::unsafe_register_server_api(utility::unique_ptr server_api)
{
// we assume that the lock has been taken here.
if (http_server_api::has_listener())
diff --git a/Release/src/http/listener/http_server_asio.cpp b/Release/src/http/listener/http_server_asio.cpp
index 13b813b858..f4dc156085 100644
--- a/Release/src/http/listener/http_server_asio.cpp
+++ b/Release/src/http/listener/http_server_asio.cpp
@@ -59,7 +59,7 @@ using web::http::http_exception;
using web::http::experimental::listener::details::http_listener_impl;
using web::http::experimental::listener::http_listener_config;
-using utility::details::make_unique;
+using utility::make_unique;
namespace
{
@@ -84,8 +84,8 @@ namespace
friend class asio_server_connection;
pplx::extensibility::reader_writer_lock_t m_listeners_lock;
- std::map, iequal_to> m_listeners;
- std::unordered_map> m_registered_listeners;
+ std::map, iequal_to> m_listeners;
+ utility::unordered_map> m_registered_listeners;
bool m_started;
public:
@@ -124,7 +124,7 @@ namespace
{
private:
int m_backlog;
- std::unique_ptr m_acceptor;
+ utility::unique_ptr m_acceptor;
std::map m_listeners;
pplx::extensibility::reader_writer_lock_t m_listeners_lock;
@@ -197,7 +197,7 @@ namespace
}
private:
- void on_accept(std::unique_ptr socket, const boost::system::error_code& ec);
+ void on_accept(utility::unique_ptr socket, const boost::system::error_code& ec);
};
@@ -313,7 +313,7 @@ class asio_server_connection
typedef void (asio_server_connection::*ResponseFuncPtr) (const http_response &response, const boost::system::error_code& ec);
- std::unique_ptr m_socket;
+ utility::unique_ptr m_socket;
boost::asio::streambuf m_request_buf;
boost::asio::streambuf m_response_buf;
http_linux_server* m_p_server;
@@ -327,10 +327,10 @@ class asio_server_connection
using ssl_stream = boost::asio::ssl::stream;
- std::unique_ptr m_ssl_context;
- std::unique_ptr m_ssl_stream;
+ utility::unique_ptr m_ssl_context;
+ utility::unique_ptr m_ssl_stream;
- asio_server_connection(std::unique_ptr socket, http_linux_server* server, hostport_listener* parent)
+ asio_server_connection(utility::unique_ptr socket, http_linux_server* server, hostport_listener* parent)
: m_socket(std::move(socket))
, m_request_buf()
, m_response_buf()
@@ -348,11 +348,11 @@ class asio_server_connection
};
public:
- using refcount_ptr = std::unique_ptr;
+ using refcount_ptr = utility::unique_ptr;
- static refcount_ptr create(std::unique_ptr socket, http_linux_server* server, hostport_listener* parent)
+ static refcount_ptr create(utility::unique_ptr socket, http_linux_server* server, hostport_listener* parent)
{
- return refcount_ptr(new asio_server_connection(std::move(socket), server, parent));
+ return refcount_ptr(utility::make_unique(std::move(socket), server, parent));
}
refcount_ptr get_reference()
@@ -511,17 +511,17 @@ void hostport_listener::start()
tcp::endpoint endpoint = *resolver.resolve(query);
- m_acceptor.reset(new tcp::acceptor(service));
+ m_acceptor = utility::make_unique(service);
m_acceptor->open(endpoint.protocol());
m_acceptor->set_option(socket_base::reuse_address(true));
m_acceptor->bind(endpoint);
m_acceptor->listen(0 != m_backlog ? m_backlog : socket_base::max_connections);
- auto socket = new ip::tcp::socket(service);
- std::unique_ptr usocket(socket);
+ utility::unique_ptr usocket = utility::make_unique(socket);
+ ip::tcp::socket *socket = usocket.get();
m_acceptor->async_accept(*socket, [this, socket](const boost::system::error_code& ec)
{
- std::unique_ptr usocket(socket);
+ utility::unique_ptr usocket(socket);
this->on_accept(std::move(usocket), ec);
});
usocket.release();
@@ -564,7 +564,7 @@ will_deref_and_erase_t asio_server_connection::start_request_response()
return will_deref_and_erase_t{};
}
-void hostport_listener::on_accept(std::unique_ptr socket, const boost::system::error_code& ec)
+void hostport_listener::on_accept(utility::unique_ptr socket, const boost::system::error_code& ec)
{
// Listener closed
if (ec == boost::asio::error::operation_aborted)
@@ -602,11 +602,11 @@ void hostport_listener::on_accept(std::unique_ptr socket, const
if (m_acceptor)
{
// spin off another async accept
- auto newSocket = new ip::tcp::socket(crossplat::threadpool::shared_instance().service());
- std::unique_ptr usocket(newSocket);
+ utility::unique_ptr usocket = utility::make_unique(socket);
+ ip::tcp::socket *newSocket = usocket.get();
m_acceptor->async_accept(*newSocket, [this, newSocket](const boost::system::error_code& ec)
{
- std::unique_ptr usocket(newSocket);
+ utility::unique_ptr usocket(newSocket);
this->on_accept(std::move(usocket), ec);
});
usocket.release();
@@ -615,7 +615,7 @@ void hostport_listener::on_accept(std::unique_ptr socket, const
will_deref_and_erase_t asio_server_connection::handle_http_line(const boost::system::error_code& ec)
{
- m_request = http_request::_create_request(make_unique());
+ m_request = http_request::_create_request(utility::make_unique());
if (ec)
{
// client closed connection
@@ -1307,13 +1307,13 @@ pplx::task http_linux_server::register_listener(http_listener_impl* listen
try
{
- m_registered_listeners[listener] = make_unique();
+ m_registered_listeners[listener] = utility::make_unique();
auto found_hostport_listener = m_listeners.find(hostport);
if (found_hostport_listener == m_listeners.end())
{
found_hostport_listener = m_listeners.insert(
- std::make_pair(hostport, make_unique(this, hostport, is_https, listener->configuration()))).first;
+ std::make_pair(hostport, utility::make_unique(this, hostport, is_https, listener->configuration()))).first;
if (m_started)
{
@@ -1355,7 +1355,7 @@ pplx::task http_linux_server::unregister_listener(http_listener_impl* list
}
// Second remove the listener form listener collection
- std::unique_ptr pListenerLock = nullptr;
+ utility::unique_ptr pListenerLock;
{
pplx::extensibility::scoped_rw_lock_t lock(m_listeners_lock);
pListenerLock = std::move(m_registered_listeners[listener]);
@@ -1390,9 +1390,9 @@ namespace experimental
namespace details
{
-std::unique_ptr make_http_asio_server()
+utility::unique_ptr make_http_asio_server()
{
- return make_unique();
+ return utility::make_unique();
}
}}}}
diff --git a/Release/src/http/listener/http_server_httpsys.cpp b/Release/src/http/listener/http_server_httpsys.cpp
index 8da74d0083..f3bd54285b 100644
--- a/Release/src/http/listener/http_server_httpsys.cpp
+++ b/Release/src/http/listener/http_server_httpsys.cpp
@@ -104,7 +104,7 @@ static utility::string_t HttpServerAPIKnownHeaders[] =
static void char_to_wstring(utf16string &dest, const char * src)
{
- dest = utility::conversions::to_utf16string(std::string(src));
+ dest = utility::conversions::to_utf16string(src);
}
http::method parse_request_method(const HTTP_REQUEST *p_request)
@@ -300,7 +300,7 @@ pplx::task http_windows_server::register_listener(_In_ web::http::experime
HttpCloseUrlGroup(urlGroupId);
throw std::invalid_argument("Error: http_listener is already registered");
}
- _M_registeredListeners[pListener] = std::unique_ptr(new listener_registration(urlGroupId));
+ _M_registeredListeners[pListener] = utility::make_unique(urlGroupId);
}
// Associate Url group with request queue.
@@ -326,7 +326,7 @@ pplx::task http_windows_server::unregister_listener(_In_ web::http::experi
return pplx::create_task([=]()
{
// First remove listener registration.
- std::unique_ptr registration;
+ utility::unique_ptr registration;
{
pplx::extensibility::scoped_rw_lock_t lock(_M_listenersLock);
registration = std::move(_M_registeredListeners[pListener]);
@@ -445,8 +445,8 @@ void http_windows_server::receive_requests()
}
// Start processing the request
- auto pContext = new windows_request_context();
- auto pRequestContext = std::unique_ptr<_http_server_context>(pContext);
+ utility::unique_ptr pRequestContext = utility::make_unique();
+ windows_request_context* pContext = pRequestContext.get();
http_request msg = http_request::_create_request(std::move(pRequestContext));
pContext->async_process_request(p_request.RequestId, msg, bytes_received);
}
@@ -502,7 +502,7 @@ void windows_request_context::async_process_request(HTTP_REQUEST_ID request_id,
// Save the http_request as the member of windows_request_context for the callback use.
m_msg = msg;
- m_request_buffer = std::unique_ptr(new unsigned char[msl::safeint3::SafeInt(headers_size)]);
+ m_request_buffer = utility::make_unique(msl::safeint3::SafeInt(headers_size));
m_request = (HTTP_REQUEST *) m_request_buffer.get();
// The read_headers_io_completion callback function.
@@ -539,7 +539,7 @@ void windows_request_context::read_headers_io_completion(DWORD error_code, DWORD
}
else
{
- std::string badRequestMsg;
+ utility::string badRequestMsg;
try
{
// HTTP_REQUEST::pRawUrl contains the raw URI that came across the wire.
@@ -560,7 +560,7 @@ void windows_request_context::read_headers_io_completion(DWORD error_code, DWORD
m_msg._get_impl()->_set_http_version({ (uint8_t)m_request->Version.MajorVersion, (uint8_t)m_request->Version.MinorVersion });
// Retrieve the remote IP address
- std::vector remoteAddressBuffer(50);
+ utility::vector remoteAddressBuffer(50);
if (m_request->Address.pRemoteAddress->sa_family == AF_INET6)
{
@@ -797,13 +797,13 @@ void windows_request_context::async_process_response()
HTTP_RESPONSE win_api_response;
ZeroMemory(&win_api_response, sizeof(win_api_response));
win_api_response.StatusCode = m_response.status_code();
- const std::string reason = utf16_to_utf8(m_response.reason_phrase());
+ const utility::string reason = utf16_to_utf8(m_response.reason_phrase());
win_api_response.pReason = reason.c_str();
win_api_response.ReasonLength = (USHORT)reason.size();
size_t content_length = m_response._get_impl()->_get_content_length();
- m_headers = std::unique_ptr(new HTTP_UNKNOWN_HEADER[msl::safeint3::SafeInt(m_response.headers().size())]);
+ m_headers = utility::make_unique(msl::safeint3::SafeInt(m_response.headers().size()));
m_headers_buffer.resize(msl::safeint3::SafeInt(m_response.headers().size()) * 2);
win_api_response.Headers.UnknownHeaderCount = (USHORT)m_response.headers().size();
@@ -1049,9 +1049,9 @@ void windows_request_context::cancel_request(std::exception_ptr except_ptr)
}
}
-std::unique_ptr make_http_httpsys_server()
+utility::unique_ptr make_http_httpsys_server()
{
- return std::make_unique();
+ return utility::make_unique();
}
}}}}
diff --git a/Release/src/http/listener/http_server_httpsys.h b/Release/src/http/listener/http_server_httpsys.h
index 2523d62e4e..6ec42821c7 100644
--- a/Release/src/http/listener/http_server_httpsys.h
+++ b/Release/src/http/listener/http_server_httpsys.h
@@ -132,10 +132,10 @@ struct windows_request_context : http::details::_http_server_context
size_t m_remaining_to_write;
HTTP_REQUEST *m_request;
- std::unique_ptr m_request_buffer;
+ utility::unique_ptr m_request_buffer;
- std::unique_ptr m_headers;
- std::vector m_headers_buffer;
+ utility::unique_ptr m_headers;
+ utility::vector m_headers_buffer;
http_overlapped m_overlapped;
@@ -153,7 +153,7 @@ struct windows_request_context : http::details::_http_server_context
// Cancels this request.
void cancel_request(std::exception_ptr except_ptr);
- std::vector m_body_data;
+ utility::vector m_body_data;
};
///
@@ -221,7 +221,7 @@ class http_windows_server : public http_server
// Registered listeners
pplx::extensibility::reader_writer_lock_t _M_listenersLock;
- std::unordered_map> _M_registeredListeners;
+ utility::unordered_map> _M_registeredListeners;
// HTTP Server API server session id.
HTTP_SERVER_SESSION_ID m_serverSessionId;
diff --git a/Release/src/http/listener/http_server_impl.h b/Release/src/http/listener/http_server_impl.h
index 6a4380b708..5856f33846 100644
--- a/Release/src/http/listener/http_server_impl.h
+++ b/Release/src/http/listener/http_server_impl.h
@@ -12,7 +12,7 @@ namespace experimental
namespace details
{
-std::unique_ptr make_http_httpsys_server();
-std::unique_ptr make_http_asio_server();
+utility::unique_ptr make_http_httpsys_server();
+utility::unique_ptr make_http_asio_server();
}}}}
diff --git a/Release/src/http/oauth/oauth1.cpp b/Release/src/http/oauth/oauth1.cpp
index 37c71deb22..762a7f6876 100644
--- a/Release/src/http/oauth/oauth1.cpp
+++ b/Release/src/http/oauth/oauth1.cpp
@@ -49,13 +49,13 @@ namespace experimental
// Code analysis complains even though there is no bug.
#pragma warning(push)
#pragma warning(disable : 6102)
-std::vector oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
+utility::vector oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
{
NTSTATUS status;
BCRYPT_ALG_HANDLE alg_handle = nullptr;
BCRYPT_HASH_HANDLE hash_handle = nullptr;
- std::vector hash;
+ utility::vector hash;
DWORD hash_len = 0;
ULONG result_len = 0;
@@ -110,7 +110,7 @@ using namespace Windows::Security::Cryptography;
using namespace Windows::Security::Cryptography::Core;
using namespace Windows::Storage::Streams;
-std::vector oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
+utility::vector oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
{
Platform::String^ data_str = ref new Platform::String(data.c_str());
Platform::String^ key_str = ref new Platform::String(key.c_str());
@@ -124,14 +124,14 @@ std::vector oauth1_config::_hmac_sha1(const utility::string_t& ke
Platform::Array^ arr;
CryptographicBuffer::CopyToByteArray(signed_buffer, &arr);
- return std::vector(arr->Data, arr->Data + arr->Length);
+ return utility::vector(arr->Data, arr->Data + arr->Length);
}
#else // Linux, Mac OS X
#include
-std::vector oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
+utility::vector oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
{
unsigned char digest[HMAC_MAX_MD_CBLOCK];
unsigned int digest_len = 0;
@@ -140,7 +140,7 @@ std::vector oauth1_config::_hmac_sha1(const utility::string_t& ke
(const unsigned char*) data.c_str(), data.length(),
digest, &digest_len);
- return std::vector(digest, digest + digest_len);
+ return utility::vector(digest, digest + digest_len);
}
#endif
@@ -168,8 +168,8 @@ utility::string_t oauth1_config::_build_normalized_parameters(web::http::uri u,
{
// While map sorts items by keys it doesn't take value into account.
// We need to sort the query parameters separately.
- std::map queries_map = http::uri::split_query(std::move(u).query());
- std::vector queries;
+ utility::map