Skip to content

Commit 3537d1e

Browse files
committed
Merge from TFS 1254697
1 parent 29f12b6 commit 3537d1e

File tree

21 files changed

+491
-234
lines changed

21 files changed

+491
-234
lines changed

Release/include/cpprest/fileio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace pplx = Concurrency;
4040

4141
#include "cpprest/xxpublic.h"
4242

43-
#ifdef WIN32
43+
#ifdef _MS_WINDOWS
4444
#include <cstdint>
4545
#endif
4646

Release/include/cpprest/http_client.h

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ namespace http
6666
namespace client
6767
{
6868

69-
// credentials class has been moved from web::http::client namespace to web namespace.
69+
// credentials and web_proxy class has been moved from web::http::client namespace to web namespace.
7070
// The below using declarations ensure we dont break existing code.
71-
// Please use the web::credentials class going forward.
71+
// Please use the web::credentials and web::web_proxy class going forward.
7272
using web::credentials;
73+
using web::web_proxy;
7374

7475
#ifdef _MS_WINDOWS
7576
namespace details {
@@ -81,87 +82,6 @@ namespace details {
8182
}
8283
#endif // _MS_WINDOWS
8384

84-
/// <summary>
85-
/// web_proxy represents the concept of the web proxy, which can be auto-discovered,
86-
/// disabled, or specified explicitly by the user
87-
/// </summary>
88-
class web_proxy
89-
{
90-
enum web_proxy_mode_internal{ use_default_, use_auto_discovery_, disabled_, user_provided_ };
91-
public:
92-
enum web_proxy_mode{ use_default = use_default_, use_auto_discovery = use_auto_discovery_, disabled = disabled_};
93-
94-
/// <summary>
95-
/// Constructs a proxy with the default settings.
96-
/// </summary>
97-
web_proxy() : m_address(_XPLATSTR("")), m_mode(use_default_) {}
98-
99-
/// <summary>
100-
/// Creates a proxy with specified mode.
101-
/// </summary>
102-
/// <param name="mode">Mode to use.</param>
103-
web_proxy( web_proxy_mode mode ) : m_address(_XPLATSTR("")), m_mode(static_cast<web_proxy_mode_internal>(mode)) {}
104-
105-
/// <summary>
106-
/// Creates a proxy explicitly with provided address.
107-
/// </summary>
108-
/// <param name="address">Proxy URI to use.</param>
109-
web_proxy( http::uri address ) : m_address(address), m_mode(user_provided_) {}
110-
111-
/// <summary>
112-
/// Gets this proxy's URI address. Returns an empty URI if not explicitly set by user.
113-
/// </summary>
114-
/// <returns>A reference to this proxy's URI.</returns>
115-
const http::uri& address() const { return m_address; }
116-
117-
/// <summary>
118-
/// Gets the credentials used for authentication with this proxy.
119-
/// </summary>
120-
/// <returns>Credentials to for this proxy.</returns>
121-
const http::client::credentials& credentials() const { return m_credentials; }
122-
123-
/// <summary>
124-
/// Sets the credentials to use for authentication with this proxy.
125-
/// </summary>
126-
/// <param name="cred">Credentials to use for this proxy.</param>
127-
void set_credentials(http::client::credentials cred) {
128-
if( m_mode == disabled_ )
129-
{
130-
throw std::invalid_argument("Cannot attach credentials to a disabled proxy");
131-
}
132-
m_credentials = std::move(cred);
133-
}
134-
135-
/// <summary>
136-
/// Checks if this proxy was constructed with default settings.
137-
/// </summary>
138-
/// <returns>True if default, false otherwise.</param>
139-
bool is_default() const { return m_mode == use_default_; }
140-
141-
/// <summary>
142-
/// Checks if using a proxy is disabled.
143-
/// </summary>
144-
/// <returns>True if disabled, false otherwise.</returns>
145-
bool is_disabled() const { return m_mode == disabled_; }
146-
147-
/// <summary>
148-
/// Checks if the auto discovery protocol, WPAD, is to be used.
149-
/// </summary>
150-
/// <returns>True if auto discovery enabled, false otherwise.</returns>
151-
bool is_auto_discovery() const { return m_mode == use_auto_discovery_; }
152-
153-
/// <summary>
154-
/// Checks if a proxy address is explicitly specified by the user.
155-
/// </summary>
156-
/// <returns>True if a proxy address was explicitly specified, false otherwise.</returns>
157-
bool is_specified() const { return m_mode == user_provided_; }
158-
159-
private:
160-
http::uri m_address;
161-
web_proxy_mode_internal m_mode;
162-
http::client::credentials m_credentials;
163-
};
164-
16585
/// <summary>
16686
/// HTTP client configuration class, used to set the possible configuration options
16787
/// used to create an http_client instance.

Release/include/cpprest/http_msg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ namespace pplx = Concurrency;
4747
#include "cpprest/streams.h"
4848
#include "cpprest/containerstream.h"
4949

50+
#ifndef _MS_WINDOWS
51+
#include <boost/algorithm/string/predicate.hpp>
52+
#endif
53+
5054
namespace web {
5155

5256
/// <summary>

Release/include/cpprest/targetver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
3232
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
3333

34-
#ifdef WIN32
34+
#ifdef _WIN32
3535
#ifdef CPPREST_TARGET_XP
3636
#include <winsdkver.h>
3737
#ifndef _WIN32_WINNT

Release/include/cpprest/web_utilities.h

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
namespace web
3434
{
35-
namespace http { namespace client {
3635
class web_proxy;
36+
namespace http { namespace client {
3737
class http_client_config;
3838
}}
3939

@@ -73,7 +73,7 @@ class credentials
7373
bool is_set() const { return m_is_set; }
7474

7575
private:
76-
friend class web::http::client::web_proxy;
76+
friend class web::web_proxy;
7777
friend class web::http::client::http_client_config;
7878
friend class web::experimental::web_sockets::client::websocket_client_config;
7979

@@ -83,6 +83,88 @@ class credentials
8383
utility::string_t m_password;
8484
bool m_is_set;
8585
};
86+
87+
/// <summary>
88+
/// web_proxy represents the concept of the web proxy, which can be auto-discovered,
89+
/// disabled, or specified explicitly by the user
90+
/// </summary>
91+
class web_proxy
92+
{
93+
enum web_proxy_mode_internal{ use_default_, use_auto_discovery_, disabled_, user_provided_ };
94+
public:
95+
enum web_proxy_mode{ use_default = use_default_, use_auto_discovery = use_auto_discovery_, disabled = disabled_};
96+
97+
/// <summary>
98+
/// Constructs a proxy with the default settings.
99+
/// </summary>
100+
web_proxy() : m_address(_XPLATSTR("")), m_mode(use_default_) {}
101+
102+
/// <summary>
103+
/// Creates a proxy with specified mode.
104+
/// </summary>
105+
/// <param name="mode">Mode to use.</param>
106+
web_proxy( web_proxy_mode mode ) : m_address(_XPLATSTR("")), m_mode(static_cast<web_proxy_mode_internal>(mode)) {}
107+
108+
/// <summary>
109+
/// Creates a proxy explicitly with provided address.
110+
/// </summary>
111+
/// <param name="address">Proxy URI to use.</param>
112+
web_proxy( uri address ) : m_address(address), m_mode(user_provided_) {}
113+
114+
/// <summary>
115+
/// Gets this proxy's URI address. Returns an empty URI if not explicitly set by user.
116+
/// </summary>
117+
/// <returns>A reference to this proxy's URI.</returns>
118+
const uri& address() const { return m_address; }
119+
120+
/// <summary>
121+
/// Gets the credentials used for authentication with this proxy.
122+
/// </summary>
123+
/// <returns>Credentials to for this proxy.</returns>
124+
const credentials& credentials() const { return m_credentials; }
125+
126+
/// <summary>
127+
/// Sets the credentials to use for authentication with this proxy.
128+
/// </summary>
129+
/// <param name="cred">Credentials to use for this proxy.</param>
130+
void set_credentials(web::credentials cred) {
131+
if( m_mode == disabled_ )
132+
{
133+
throw std::invalid_argument("Cannot attach credentials to a disabled proxy");
134+
}
135+
m_credentials = std::move(cred);
136+
}
137+
138+
/// <summary>
139+
/// Checks if this proxy was constructed with default settings.
140+
/// </summary>
141+
/// <returns>True if default, false otherwise.</param>
142+
bool is_default() const { return m_mode == use_default_; }
143+
144+
/// <summary>
145+
/// Checks if using a proxy is disabled.
146+
/// </summary>
147+
/// <returns>True if disabled, false otherwise.</returns>
148+
bool is_disabled() const { return m_mode == disabled_; }
149+
150+
/// <summary>
151+
/// Checks if the auto discovery protocol, WPAD, is to be used.
152+
/// </summary>
153+
/// <returns>True if auto discovery enabled, false otherwise.</returns>
154+
bool is_auto_discovery() const { return m_mode == use_auto_discovery_; }
155+
156+
/// <summary>
157+
/// Checks if a proxy address is explicitly specified by the user.
158+
/// </summary>
159+
/// <returns>True if a proxy address was explicitly specified, false otherwise.</returns>
160+
bool is_specified() const { return m_mode == user_provided_; }
161+
162+
private:
163+
uri m_address;
164+
web_proxy_mode_internal m_mode;
165+
web::credentials m_credentials;
166+
};
167+
86168
}
87169

88170
#endif

Release/include/cpprest/ws_client.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ class websocket_client_config
8282
websocket_client_config()
8383
{}
8484

85+
/// <summary>
86+
/// Get the web proxy object
87+
/// </summary>
88+
/// <returns>A reference to the web proxy object.</returns>
89+
const web_proxy& proxy() const
90+
{
91+
return m_proxy;
92+
}
93+
94+
/// <summary>
95+
/// Set the web proxy object
96+
/// </summary>
97+
/// <param name="proxy">The web proxy object.</param>
98+
void set_proxy(web_proxy proxy)
99+
{
100+
m_proxy = std::move(proxy);
101+
}
102+
85103
/// <summary>
86104
/// Get the client credentials
87105
/// </summary>
@@ -116,6 +134,7 @@ class websocket_client_config
116134
const web::http::http_headers &headers() const { return m_headers; }
117135

118136
private:
137+
web::web_proxy m_proxy;
119138
web::credentials m_credentials;
120139
web::http::http_headers m_headers;
121140
};

Release/include/cpprest/ws_msg.h

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,14 @@ class _websocket_message
8484
_ASYNCRTIMP void set_body(concurrency::streams::istream instream);
8585

8686
/// <summary>
87-
/// Set the stream through which the message body could be read
87+
/// Get the streambuf for the message
8888
/// </summary>
89-
void set_instream(concurrency::streams::istream instream) { m_inStream = instream; }
89+
concurrency::streams::streambuf<uint8_t>& streambuf() { return m_buf; }
9090

9191
/// <summary>
92-
/// Get the stream through which the message body could be read
92+
/// Set the streambuf for the message
9393
/// </summary>
94-
concurrency::streams::istream instream() const { return m_inStream; }
95-
96-
/// <summary>
97-
/// Set the stream through which the message body could be written
98-
/// </summary>
99-
void set_outstream(concurrency::streams::ostream outstream) { m_outStream = outstream; }
100-
101-
/// <summary>
102-
/// Get the stream through which the message body could be written
103-
/// </summary>
104-
concurrency::streams::ostream outstream() const { return m_outStream; }
94+
void set_streambuf(concurrency::streams::streambuf<uint8_t> buf) { m_buf = buf; }
10595

10696
void set_msg_type(websocket_message_type msg_type) { m_msg_type = msg_type; }
10797

@@ -124,15 +114,7 @@ class _websocket_message
124114

125115
protected:
126116

127-
/// <summary>
128-
/// Stream to read the message body.
129-
/// </summary>
130-
concurrency::streams::istream m_inStream;
131-
132-
/// <summary>
133-
/// Stream to write the message body.
134-
/// </summary>
135-
concurrency::streams::ostream m_outStream;
117+
concurrency::streams::streambuf<uint8_t> m_buf;
136118

137119
websocket_message_type m_msg_type;
138120

@@ -254,7 +236,7 @@ class websocket_incoming_message
254236
/// </remarks>
255237
concurrency::streams::istream body() const
256238
{
257-
return _m_impl->instream();
239+
return _m_impl->streambuf().create_istream();
258240
}
259241

260242
/// <summary>

Release/include/cpprest/xxpublic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#pragma once
3030

3131
#ifndef _MS_WINDOWS
32-
#if defined(WIN32) || defined(__cplusplus_winrt)
32+
#if defined(_WIN32) || defined(__cplusplus_winrt)
3333
#define _MS_WINDOWS
3434
#endif
3535
#endif // _MS_WINDOWS

Release/include/pplx/pplx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#endif
3636

3737
#ifndef _MS_WINDOWS
38-
#if defined(WIN32) || defined(__cplusplus_winrt)
38+
#if defined(_WIN32) || defined(__cplusplus_winrt)
3939
#define _MS_WINDOWS
4040
#endif
4141
#endif // _MS_WINDOWS

Release/samples/BingRequest/BingRequest110/BingRequest110.vcxproj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@
7676
<PlatformToolset>v110</PlatformToolset>
7777
</PropertyGroup>
7878
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
79-
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))\Build\Release.Product.Settings" />
79+
80+
<!-- Normally these settings would be include by Release.Product.Settings,
81+
however they aren't to cover the case of a project without WIN32 defined -->
82+
<PropertyGroup>
83+
<BuildRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))</BuildRoot>
84+
<OutputPath>$(BuildRoot)\Binaries\$(Platform)\$(Configuration)\</OutputPath>
85+
<OutDir>$(OutputPath)</OutDir>
86+
<CasablancaSrcDir>$(BuildRoot)\Release\src</CasablancaSrcDir>
87+
<CasablancaIncludeDir>$(BuildRoot)\Release\include</CasablancaIncludeDir>
88+
</PropertyGroup>
89+
8090
<ImportGroup Label="ExtensionSettings" />
8191
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8292
<ClCompile>

0 commit comments

Comments
 (0)