Skip to content

Commit 489bb90

Browse files
committed
Merge branch 'development' of https://git01.codeplex.com/forks/tsone/casadev into development
2 parents 9997f43 + 0e31947 commit 489bb90

37 files changed

+684
-187
lines changed

Build/version.props

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
<CppRestBaseFileName>cpprest</CppRestBaseFileName>
55
<CppRestSDKVersionMajor>2</CppRestSDKVersionMajor>
66
<CppRestSDKVersionMinor>0</CppRestSDKVersionMinor>
7-
<CppRestSDKVersionRevision>0</CppRestSDKVersionRevision>
7+
<CppRestSDKVersionRevision>1</CppRestSDKVersionRevision>
88
<CppRestSDKVersionFileSuffix>$(CppRestSDKVersionMajor)_$(CppRestSDKVersionMinor)</CppRestSDKVersionFileSuffix>
99
<CppRestSDKVersionString>$(CppRestSDKVersionMajor).$(CppRestSDKVersionMinor)</CppRestSDKVersionString>
1010
</PropertyGroup>
11-
<!--
12-
Note: remember to regenerate guiddefs.wxi files using gen_guids_for_msi.ps1 whenever major or minor version file changes
13-
-->
1411
</Project>

Release/include/cpprest/oauth1_handler.h

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class oauth1_methods
4848
{
4949
public:
5050
#define _OAUTH1_METHODS
51-
#define DAT(a,b) const static oauth1_method a;
51+
#define DAT(a,b) _ASYNCRTIMP static const oauth1_method a;
5252
#include "cpprest/http_constants.dat"
5353
#undef _OAUTH1_METHODS
5454
#undef DAT
@@ -71,8 +71,30 @@ struct oauth1_config
7171
{
7272
}
7373

74+
const utility::string_t& key() const { return m_key; }
75+
void set_key(utility::string_t key) { m_key = std::move(key); }
76+
77+
const utility::string_t& secret() const { return m_secret; }
78+
void set_secret(utility::string_t secret) { m_secret = std::move(secret); }
79+
80+
const utility::string_t& token() const { return m_token; }
81+
void set_token(utility::string_t token) { m_token = std::move(token); }
82+
83+
const utility::string_t& token_secret() const { return m_token_secret; }
84+
void set_token_secret(utility::string_t token_secret) { m_token_secret = std::move(token_secret); }
85+
86+
const oauth1_method& method() const { return m_method; }
87+
void set_method(oauth1_method method) { m_method = std::move(method); }
88+
89+
const utility::string_t& realm() const { return m_realm; }
90+
void set_realm(utility::string_t realm) { m_realm = std::move(realm); }
91+
7492
bool is_enabled() const { return !m_key.empty() && !m_secret.empty() && !m_token.empty() && !m_token_secret.empty(); }
7593

94+
private:
95+
friend class http_client_config;
96+
oauth1_config() {}
97+
7698
// Required.
7799
utility::string_t m_key;
78100
utility::string_t m_secret;
@@ -82,10 +104,6 @@ struct oauth1_config
82104

83105
// Optional.
84106
utility::string_t m_realm;
85-
86-
private:
87-
friend class http_client_config;
88-
oauth1_config() {}
89107
};
90108

91109

@@ -103,16 +121,16 @@ class oauth1_handler : public http_pipeline_stage
103121
void set_config(oauth1_config config) { m_config = std::move(config); }
104122
const oauth1_config& get_config() const { return m_config; }
105123

106-
virtual pplx::task<http_response> propagate(http_request request) override;
124+
_ASYNCRTIMP virtual pplx::task<http_response> propagate(http_request request) override;
107125

108-
utility::string_t _generate_nonce();
126+
_ASYNCRTIMP utility::string_t _generate_nonce();
109127

110-
utility::string_t _build_signature_base_string(http_request request, utility::string_t timestamp, utility::string_t nonce) const;
128+
_ASYNCRTIMP utility::string_t _build_signature_base_string(http_request request, utility::string_t timestamp, utility::string_t nonce) const;
111129

112-
utility::string_t _build_hmac_sha1_signature(http_request request, utility::string_t timestamp, utility::string_t nonce) const;
130+
_ASYNCRTIMP utility::string_t _build_hmac_sha1_signature(http_request request, utility::string_t timestamp, utility::string_t nonce) const;
113131
// TODO: RSA-SHA1
114132
// utility::string_t _build_rsa_sha1_signature(http_request request, utility::string_t timestamp, utility::string_t nonce) const;
115-
utility::string_t _build_plaintext_signature() const;
133+
_ASYNCRTIMP utility::string_t _build_plaintext_signature() const;
116134

117135
private:
118136
static utility::string_t _generate_timestamp();

Release/include/cpprest/oauth2_handler.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ struct oauth2_config
4646
{
4747
oauth2_config(utility::string_t token) : m_token(std::move(token)) {}
4848

49-
bool is_enabled() const { return !m_token.empty(); }
49+
const utility::string_t& token() const { return m_token; }
50+
void set_token(utility::string_t token) { m_token = std::move(token); }
5051

51-
utility::string_t m_token;
52+
bool is_enabled() const { return !m_token.empty(); }
5253

5354
private:
5455
friend class http_client_config;
5556
oauth2_config() {}
57+
58+
utility::string_t m_token;
5659
};
5760

5861

@@ -71,7 +74,7 @@ class oauth2_handler : public http_pipeline_stage
7174
{
7275
if (m_config.is_enabled())
7376
{
74-
request.headers().add(_XPLATSTR("Authorization"), _XPLATSTR("Bearer ") + m_config.m_token);
77+
request.headers().add(_XPLATSTR("Authorization"), _XPLATSTR("Bearer ") + m_config.token());
7578
}
7679
return next_stage()->propagate(request);
7780
}

Release/include/cpprest/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* ==--==
1717
*/
18-
#define CPPREST_VERSION_REVISION 0
18+
#define CPPREST_VERSION_REVISION 1
1919
#define CPPREST_VERSION_MINOR 0
2020
#define CPPREST_VERSION_MAJOR 2
2121

Release/nuget/cpprestsdk.autopkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
nuget {
22
nuspec {
33
id = cpprestsdk;
4-
version : 2.0.0;
4+
version : 2.0.1;
55
title: C++ REST SDK;
66
authors: {casablancacore};
77
owners: {Microsoft, Visual C++};
@@ -11,7 +11,7 @@ nuget {
1111
requireLicenseAcceptance: true;
1212
summary: "The C++ REST SDK is a cross-platform, modern, and asynchronous library that enables developers to access and author connected applications";
1313
description: "This library is a Microsoft effort to support cloud-based client-server communication in native code using a modern asynchronous C++ API design. The C++ REST SDK (codename "Casablanca") is a project to start exploring how to best support C++ developers who want to take advantage of the radical shift in software architecture that cloud computing represents.";
14-
releaseNotes: "Release of C++ Rest SDK 2.0.0 libraries.";
14+
releaseNotes: "Release of C++ Rest SDK 2.0.1 libraries.";
1515
copyright: Copyright 2013;
1616
tags: {REST, native, C++, JSON, Casablanca, Http, Uri};
1717
};

Release/samples/Oauth1Client/Oauth1Client.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ using namespace web::http::client;
3434
// LinkedIn tokens. Fill the following based on information here:
3535
// https://developer.linkedin.com/documents/quick-start-guide
3636
//
37-
static const string_t s_linkedin_key("");
38-
static const string_t s_linkedin_secret("");
39-
static const string_t s_linkedin_user_token("");
40-
static const string_t s_linkedin_user_token_secret("");
37+
static const string_t s_linkedin_key(U(""));
38+
static const string_t s_linkedin_secret(U(""));
39+
static const string_t s_linkedin_user_token(U(""));
40+
static const string_t s_linkedin_user_token_secret(U(""));
4141

4242

4343
static void linkedin_client()
@@ -46,24 +46,24 @@ static void linkedin_client()
4646
config.set_oauth1(oauth1_config(s_linkedin_key, s_linkedin_secret,
4747
s_linkedin_user_token, s_linkedin_user_token_secret,
4848
oauth1_methods::hmac_sha1));
49-
http_client c("http://api.linkedin.com/", config);
49+
http_client c(U("http://api.linkedin.com/"), config);
5050

51-
std::cout << "Requesting user information:" << std::endl;
52-
auto user_json = c.request(methods::GET, "v1/people/~?format=json").get().extract_json().get();
53-
std::cout << "Got following JSON:" << std::endl;
54-
std::cout << user_json << std::endl;
51+
ucout << "Requesting user information:" << std::endl;
52+
auto user_json = c.request(methods::GET, U("v1/people/~?format=json")).get().extract_json().get();
53+
ucout << "Got following JSON:" << std::endl;
54+
ucout << user_json.serialize().c_str() << std::endl;
5555
}
5656

5757
static int has_key(string_t client_name, string_t key)
5858
{
5959
if (key.empty())
6060
{
61-
std::cout << "Skipped " << client_name << " client. Please supply tokens for the client." << std::endl;
61+
ucout << "Skipped " << client_name.c_str() << " client. Please supply tokens for the client." << std::endl;
6262
return 0;
6363
}
6464
else
6565
{
66-
std::cout << "Running " << client_name << " client." << std::endl;
66+
ucout << "Running " << client_name.c_str() << " client." << std::endl;
6767
return 1;
6868
}
6969
}
@@ -74,12 +74,12 @@ int wmain(int argc, wchar_t *argv[])
7474
int main(int argc, char *argv[])
7575
#endif
7676
{
77-
std::cout << "Running oauth1 sample..." << std::endl;
78-
if (has_key("LinkedIn", s_linkedin_key))
77+
ucout << "Running oauth1 sample..." << std::endl;
78+
if (has_key(U("LinkedIn"), s_linkedin_key))
7979
{
8080
linkedin_client();
8181
}
82-
std::cout << "Done." << std::endl;
82+
ucout << "Done." << std::endl;
8383
return 0;
8484
}
8585

0 commit comments

Comments
 (0)