Skip to content

Commit 2eac6f1

Browse files
committed
Merge branch 'development' of https://git01.codeplex.com/casablanca into remove_blocking_wait
2 parents 660b21c + 9de742d commit 2eac6f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1027
-492
lines changed

Build_iOS/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ execute_process(WORKING_DIRECTORY ${ARM_BINARY_DIR}
3535
add_custom_target(sim
3636
COMMAND ${CMAKE_COMMAND}
3737
--build ${SIM_BINARY_DIR}
38-
--target cpprest
3938
--config ${CMAKE_BUILD_TYPE}
4039
COMMENT "Building for i386 (simulator)"
4140
VERBATIM
@@ -45,7 +44,6 @@ add_custom_target(sim
4544
add_custom_target(arm
4645
COMMAND ${CMAKE_COMMAND}
4746
--build ${ARM_BINARY_DIR}
48-
--target cpprest
4947
--config ${CMAKE_BUILD_TYPE}
5048
COMMENT "Building for armv7, armv7s, arm64"
5149
VERBATIM

Build_iOS/configure.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ set -e
33

44
git clone https://git.gitorious.org/boostoniphone/galbraithjosephs-boostoniphone.git boostoniphone
55
pushd boostoniphone
6-
sed -e 's/\${IPHONE_SDKVERSION:=7.0}/\${IPHONE_SDKVERSION:=8.0}/' -i .bak boost.sh
7-
sed -e 's/\${BOOST_LIBS:=".*"}/\${BOOST_LIBS:="random thread filesystem regex locale system date_time"}/g' -i .bak boost.sh
6+
git apply ../fix_boost_version.patch
87
./boost.sh
98
pushd ios/framework/boost.framework/Versions/A
109
mkdir Headers2

Build_iOS/fix_boost_version.patch

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From e5b3bf1392d3dc04f1391c4ad60118a394b5219f Mon Sep 17 00:00:00 2001
2+
From: Steve Gates <[email protected]>
3+
Date: Thu, 30 Oct 2014 17:42:43 -0700
4+
Subject: [PATCH] Fixing boost.sh to use Boost version 1.56 and iOS 8.0.
5+
6+
---
7+
boost.sh | 6 +++---
8+
1 file changed, 3 insertions(+), 3 deletions(-)
9+
10+
diff --git a/boost.sh b/boost.sh
11+
index 8847aac..2a76aec 100755
12+
--- a/boost.sh
13+
+++ b/boost.sh
14+
@@ -18,8 +18,8 @@
15+
# same directory as this script, and run "./boost.sh". Grab a cuppa. And voila.
16+
#===============================================================================
17+
18+
-: ${BOOST_LIBS:="filesystem date_time system"}
19+
-: ${IPHONE_SDKVERSION:=7.0}
20+
+: ${BOOST_LIBS:="thread chrono filesystem regex locale system random"}
21+
+: ${IPHONE_SDKVERSION:=8.0}
22+
: ${OSX_SDKVERSION:=10.9}
23+
: ${XCODE_ROOT:=`xcode-select -print-path`}
24+
: ${EXTRA_CPPFLAGS:="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -std=c++11 -stdlib=libc++"}
25+
@@ -84,7 +84,7 @@ updateBoost()
26+
then
27+
git checkout $BOOST_SRC/tools/build/v2/user-config.jam
28+
else
29+
- git clone --recursive https://github.com/boostorg/boost.git $BOOST_SRC
30+
+ git clone --recursive --branch boost-1.56.0 https://github.com/boostorg/boost.git $BOOST_SRC
31+
pushd $BOOST_SRC
32+
./bootstrap.sh
33+
./b2 headers
34+
--
35+
1.9.3 (Apple Git-50)
36+

Build_iOS/ios_cmake_clang3.patch

Lines changed: 0 additions & 34 deletions
This file was deleted.

Release/include/cpprest/astreambuf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace concurrency = Concurrency;
6262

6363
namespace Concurrency
6464
{
65-
/// Library for asychronous streams.
65+
/// Library for asynchronous streams.
6666
namespace streams
6767
{
6868
/// <summary>

Release/include/cpprest/http_client_impl.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,20 @@ class request_context
148148
finish();
149149
}
150150

151-
void report_error(unsigned long error_code, const utility::string_t & errorMessage)
151+
void report_error(unsigned long error_code, const std::string &errorMessage)
152152
{
153-
report_exception(http_exception((int)error_code, errorMessage));
153+
report_exception(http_exception(static_cast<int>(error_code), errorMessage));
154154
}
155155

156+
#ifdef _MS_WINDOWS
157+
void report_error(unsigned long error_code, const std::wstring &errorMessage)
158+
{
159+
report_exception(http_exception(static_cast<int>(error_code), errorMessage));
160+
}
161+
#endif
162+
156163
template<typename _ExceptionType>
157-
void report_exception(_ExceptionType e)
164+
void report_exception(const _ExceptionType &e)
158165
{
159166
report_exception(std::make_exception_ptr(e));
160167
}

Release/include/cpprest/http_msg.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ class http_exception : public std::exception
168168
http_exception(const utility::string_t &whatArg)
169169
: m_msg(utility::conversions::to_utf8string(whatArg)) {}
170170

171+
#ifdef _MS_WINDOWS
172+
/// <summary>
173+
/// Creates an <c>http_exception</c> with just a string message and no error code.
174+
/// </summary>
175+
/// <param name="whatArg">Error message string.</param>
176+
http_exception(std::string whatArg) : m_msg(std::move(whatArg)) {}
177+
#endif
178+
171179
/// <summary>
172180
/// Creates an <c>http_exception</c> with from a error code using the current platform error category.
173181
/// The message of the error code will be used as the what() string message.
@@ -189,6 +197,18 @@ class http_exception : public std::exception
189197
m_msg(utility::conversions::to_utf8string(whatArg))
190198
{}
191199

200+
#ifdef _MS_WINDOWS
201+
/// <summary>
202+
/// Creates an <c>http_exception</c> with from a error code using the current platform error category.
203+
/// </summary>
204+
/// <param name="errorCode">Error code value.</param>
205+
/// <param name="whatArg">Message to use in what() string.</param>
206+
http_exception(int errorCode, std::string whatArg) :
207+
m_errorCode(utility::details::create_error_code(errorCode)),
208+
m_msg(std::move(whatArg))
209+
{}
210+
#endif
211+
192212
/// <summary>
193213
/// Creates an <c>http_exception</c> with from a error code and category. The message of the error code will be used
194214
/// as the <c>what</c> string message.
@@ -200,8 +220,10 @@ class http_exception : public std::exception
200220
m_msg = m_errorCode.message();
201221
}
202222

203-
~http_exception() CPPREST_NOEXCEPT {}
204-
223+
/// <summary>
224+
/// Gets a string identifying the cause of the exception.
225+
/// </summary>
226+
/// <returns>A null terminated character string.</returns>
205227
const char* what() const CPPREST_NOEXCEPT
206228
{
207229
return m_msg.c_str();

Release/include/cpprest/oauth1.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ namespace web
3535
{
3636
namespace http
3737
{
38+
namespace client
39+
{
40+
// Forward declaration to avoid circular include dependency.
41+
class http_client_config;
42+
}
43+
3844
/// oAuth 1.0 library.
3945
namespace oauth1
4046
{

Release/include/cpprest/oauth2.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ namespace web
3535
{
3636
namespace http
3737
{
38+
namespace client
39+
{
40+
// Forward declaration to avoid circular include dependency.
41+
class http_client_config;
42+
}
43+
3844
/// oAuth 2.0 library.
3945
namespace oauth2
4046
{

Release/include/cpprest/web_utilities.h

Lines changed: 111 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,144 @@
3232

3333
namespace web
3434
{
35-
class web_proxy;
36-
namespace http { namespace client {
37-
class http_client_config;
38-
}}
3935

40-
namespace experimental { namespace websockets { namespace client {
41-
class websocket_client_config;
36+
namespace http { namespace client { namespace details {
37+
class winhttp_client;
38+
class winrt_client;
4239
}}}
40+
namespace websockets { namespace client { namespace details {
41+
class winrt_client;
42+
}}}
43+
44+
namespace details
45+
{
46+
#if defined(_MS_WINDOWS)
47+
class zero_memory_deleter
48+
{
49+
public:
50+
_ASYNCRTIMP void operator()(::utility::string_t *data) const;
51+
};
52+
typedef std::unique_ptr<std::wstring, zero_memory_deleter> plaintext_string;
53+
#if defined(__cplusplus_winrt)
54+
#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800)
55+
class winrt_encryption
56+
{
57+
public:
58+
winrt_encryption() {}
59+
_ASYNCRTIMP winrt_encryption(const std::wstring &data);
60+
_ASYNCRTIMP plaintext_string decrypt() const;
61+
private:
62+
::pplx::task<Windows::Storage::Streams::IBuffer ^> m_buffer;
63+
};
64+
#endif
65+
#else
66+
class win32_encryption
67+
{
68+
public:
69+
win32_encryption() {}
70+
_ASYNCRTIMP win32_encryption(const std::wstring &data);
71+
_ASYNCRTIMP ~win32_encryption();
72+
_ASYNCRTIMP plaintext_string decrypt() const;
73+
private:
74+
std::vector<char> m_buffer;
75+
size_t m_numCharacters;
76+
};
77+
#endif
78+
#endif
79+
}
4380

4481
/// <summary>
45-
/// credentials represents a set of user credentials (username and password) to be used
46-
/// for the client and proxy authentication
82+
/// Represents a set of user credentials (user name and password) to be used
83+
/// for authentication.
4784
/// </summary>
4885
class credentials
4986
{
5087
public:
51-
credentials(utility::string_t username, utility::string_t password) :
52-
m_is_set(true),
53-
m_username(std::move(username)),
54-
m_password(std::move(password))
88+
/// <summary>
89+
/// Constructs an empty set of credentials without a user name or password.
90+
/// </summary>
91+
credentials() {}
92+
93+
/// <summary>
94+
/// Constructs credentials from given user name and password.
95+
/// </summary>
96+
/// <param name="username">User name as a string.</param>
97+
/// <param name="password">Password as a string.</param>
98+
credentials(utility::string_t username, const utility::string_t &
99+
#if defined(_MS_WINDOWS)
100+
password
101+
#endif
102+
) :
103+
m_username(std::move(username))
104+
#if defined(_MS_WINDOWS)
105+
, m_password(password)
106+
#endif
55107
{}
56108

57109
/// <summary>
58110
/// The user name associated with the credentials.
59111
/// </summary>
60-
/// <returns>A reference to the username string.</returns>
61-
const utility::string_t& username() const { return m_username; }
112+
/// <returns>A string containing the user name.</returns>
113+
const utility::string_t &username() const { return m_username; }
62114

63115
/// <summary>
64116
/// The password for the user name associated with the credentials.
65117
/// </summary>
66-
/// <returns>A reference to the password string.</returns>
67-
const utility::string_t& password() const { return m_password; }
118+
/// <returns>A string containing the password.</returns>
119+
CASABLANCA_DEPRECATED("This API is deprecated for security reasons to avoid unnecessary password copies stored in plaintext.")
120+
utility::string_t password() const
121+
{
122+
#if defined(_MS_WINDOWS)
123+
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800
124+
return m_password;
125+
#else
126+
return utility::string_t(*m_password.decrypt());
127+
#endif
128+
#else
129+
throw std::runtime_error("Credentials are not supported on this platform yet.");
130+
#endif
131+
}
68132

69133
/// <summary>
70134
/// Checks if credentials have been set
71135
/// </summary>
72-
/// <returns><c>true</c> if username and password is set, <c>false</c> otherwise.</returns>
73-
bool is_set() const { return m_is_set; }
136+
/// <returns><c>true</c> if user name and password is set, <c>false</c> otherwise.</returns>
137+
bool is_set() const { return !m_username.empty(); }
74138

75139
private:
76-
friend class web::web_proxy;
77-
friend class web::http::client::http_client_config;
78-
friend class web::experimental::websockets::client::websocket_client_config;
79-
80-
credentials() : m_is_set(false) {}
140+
friend class http::client::details::winhttp_client;
141+
friend class http::client::details::winrt_client;
142+
friend class websockets::client::details::winrt_client;
143+
144+
#if defined(_MS_WINDOWS)
145+
details::plaintext_string decrypt() const
146+
{
147+
// Encryption APIs not supported on Windows Phone 8.0
148+
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800
149+
return details::plaintext_string(new ::utility::string_t(m_password));
150+
#else
151+
return m_password.decrypt();
152+
#endif
153+
}
154+
#endif
81155

82-
bool m_is_set;
83-
utility::string_t m_username;
84-
utility::string_t m_password;
156+
::utility::string_t m_username;
157+
#if defined(_MS_WINDOWS)
158+
#if defined(__cplusplus_winrt)
159+
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800
160+
::utility::string_t m_password;
161+
#else
162+
details::winrt_encryption m_password;
163+
#endif
164+
#else
165+
details::win32_encryption m_password;
166+
#endif
167+
#endif
85168
};
86169

87170
/// <summary>
88171
/// web_proxy represents the concept of the web proxy, which can be auto-discovered,
89-
/// disabled, or specified explicitly by the user
172+
/// disabled, or specified explicitly by the user.
90173
/// </summary>
91174
class web_proxy
92175
{
@@ -160,7 +243,7 @@ class web_proxy
160243
bool is_specified() const { return m_mode == user_provided_; }
161244

162245
private:
163-
uri m_address;
246+
web::uri m_address;
164247
web_proxy_mode_internal m_mode;
165248
web::credentials m_credentials;
166249
};

0 commit comments

Comments
 (0)