Skip to content

Commit e0adf16

Browse files
committed
Merge branch 'development' of https://github.com/Microsoft/cpprestsdk into development
2 parents 9e81bc2 + 4ffcad6 commit e0adf16

File tree

18 files changed

+407
-105
lines changed

18 files changed

+407
-105
lines changed

CONTRIBUTORS.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ jracle
2020
gandziej
2121
adish
2222
LeonidCSIT
23-
LocutusOfBorg
2423
kreuzerkrieg
2524
evanc
2625

26+
Abinsula s.r.l.
27+
Gianfranco Costamagna (LocutusOfBorg)
28+
2729
AutoDesk Inc.
2830
Cyrille Fauvel (cyrillef)
2931

@@ -34,3 +36,6 @@ Cisco Systems
3436
Gergely Lukacsy (glukacsy)
3537

3638
thomasschaub
39+
40+
Trimble
41+
Tim Boundy (gigaplex)

Release/CMakeLists.txt

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ elseif(WIN32)
101101
option(BUILD_SHARED_LIBS "Build shared Libraries." ON)
102102
option(BUILD_TESTS "Build tests." ON)
103103
option(BUILD_SAMPLES "Build samples." ON)
104+
option(CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF)
104105
option(Boost_USE_STATIC_LIBS ON)
105106

106107
add_definitions(-DUNICODE -D_UNICODE)
@@ -114,8 +115,12 @@ elseif(WIN32)
114115
endif()
115116
add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32)
116117

117-
find_package(Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
118-
find_package(OpenSSL 1.0 REQUIRED)
118+
if (CPPREST_EXCLUDE_WEBSOCKETS)
119+
add_definitions(-DCPPREST_EXCLUDE_WEBSOCKETS=1)
120+
else()
121+
find_package(Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
122+
find_package(OpenSSL 1.0 REQUIRED)
123+
endif()
119124
else()
120125
message(FATAL_ERROR "-- Unsupported Build Platform.")
121126
endif()
@@ -134,7 +139,7 @@ elseif((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR IOS)
134139
message("-- Setting clang options")
135140

136141
set(WARNINGS "-Wall -Wextra -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls")
137-
set(OSX_SUPPRESSIONS "-Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-unused-function -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-reorder")
142+
set(OSX_SUPPRESSIONS "-Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-unused-function -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-reorder -Wno-unused-local-typedefs")
138143
set(WARNINGS "${WARNINGS} ${OSX_SUPPRESSIONS}")
139144

140145
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wno-return-type-c-linkage -Wno-unneeded-internal-declaration")
@@ -165,20 +170,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
165170

166171
# These settings can be used by the test targets
167172
set(Casablanca_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
168-
169-
find_path(WEBSOCKETPP_CONFIG websocketpp-config.cmake
170-
HINTS /usr/lib/cmake/websocketpp)
171-
find_path(WEBSOCKETPP_CONFIG_VERSION websocketpp-configVersion.cmake
172-
HINTS /usr/lib/cmake/websocketpp)
173-
if(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
174-
include(${WEBSOCKETPP_CONFIG}/websocketpp-config.cmake)
175-
include(${WEBSOCKETPP_CONFIG}/websocketpp-configVersion.cmake)
176-
message("-- Found websocketpp version " ${PACKAGE_VERSION} " on system")
177-
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${WEBSOCKETPP_INCLUDE_DIR})
178-
else(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
179-
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libs/websocketpp)
180-
message("-- websocketpp not found, using the embedded version")
181-
endif(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
173+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
174+
find_path(WEBSOCKETPP_CONFIG websocketpp-config.cmake
175+
HINTS /usr/lib/cmake/websocketpp)
176+
find_path(WEBSOCKETPP_CONFIG_VERSION websocketpp-configVersion.cmake
177+
HINTS /usr/lib/cmake/websocketpp)
178+
if(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
179+
include(${WEBSOCKETPP_CONFIG}/websocketpp-config.cmake)
180+
include(${WEBSOCKETPP_CONFIG}/websocketpp-configVersion.cmake)
181+
message("-- Found websocketpp version " ${PACKAGE_VERSION} " on system")
182+
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${WEBSOCKETPP_INCLUDE_DIR})
183+
else(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
184+
set(Casablanca_INCLUDE_DIRS ${Casablanca_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libs/websocketpp)
185+
message("-- websocketpp not found, using the embedded version")
186+
endif(WEBSOCKETPP_CONFIG AND WEBSOCKETPP_CONFIG_VERSION)
187+
else()
188+
set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
189+
endif()
182190

183191
set(Casablanca_LIBRARY ${LIB}cpprest)
184192
set(Casablanca_LIBRARIES ${Casablanca_LIBRARY} ${Boost_LIBRARIES} ${Boost_FRAMEWORK})

Release/include/cpprest/details/http_server_httpsys.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ struct windows_request_context : http::details::_http_server_context
9999
// Dispatch request to the provided http_listener.
100100
void dispatch_request_to_listener(_In_ web::http::experimental::listener::details::http_listener_impl *pListener);
101101

102+
enum class ShouldWaitForBody
103+
{
104+
Wait,
105+
DontWait
106+
};
107+
// Initialise the response task callbacks. If the body has been requested, we should wait for it to avoid race conditions.
108+
void init_response_callbacks(ShouldWaitForBody shouldWait);
109+
102110
// Read in a portion of the request body.
103111
void read_request_body_chunk();
104112

Release/include/cpprest/ws_msg.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ class websocket_outgoing_message
7373
{
7474
public:
7575

76+
#if !defined(__cplusplus_winrt)
77+
/// <summary>
78+
/// Sets a the outgoing message to be an unsolicited pong message.
79+
/// This is useful when the client side wants to check whether the server is alive.
80+
/// </summary>
81+
void set_pong_message()
82+
{
83+
this->set_message_pong();
84+
}
85+
#endif
86+
7687
/// <summary>
7788
/// Sets a UTF-8 message as the message body.
7889
/// </summary>
@@ -152,6 +163,16 @@ class websocket_outgoing_message
152163

153164
const pplx::task_completion_event<void> & body_sent() const { return m_body_sent; }
154165

166+
#if !defined(__cplusplus_winrt)
167+
void set_message_pong()
168+
{
169+
concurrency::streams::container_buffer<std::string> buffer("");
170+
m_msg_type = websocket_message_type::pong;
171+
m_length = static_cast<size_t>(buffer.size());
172+
m_body = buffer;
173+
}
174+
#endif
175+
155176
void set_message(const concurrency::streams::container_buffer<std::string> &buffer)
156177
{
157178
m_msg_type = websocket_message_type::text_message;

Release/src/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
include_directories(pch ${OPENSSL_INCLUDE_DIR})
1+
include_directories(../include pch)
2+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
3+
include_directories(${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
4+
endif()
25

36
set(SOURCES_COMMON
47
http/client/http_client_msg.cpp
@@ -67,8 +70,12 @@ elseif(WIN32)
6770
httpapi.lib
6871
Winhttp.lib
6972
)
70-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS} /Yustdafx.h /Zm200")
71-
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
73+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS}")
74+
if (${CMAKE_GENERATOR} MATCHES "Visual Studio .*")
75+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yustdafx.h /Zm200")
76+
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
77+
endif()
78+
7279
if (BUILD_SHARED_LIBS)
7380
add_definitions(-D_ASYNCRT_EXPORT -D_PPLX_EXPORT -D_USRDLL)
7481
endif()
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))\Build\version.props" />
4+
<ItemGroup Label="ProjectConfigurations">
5+
<ProjectConfiguration Include="Debug|ARM">
6+
<Configuration>Debug</Configuration>
7+
<Platform>ARM</Platform>
8+
</ProjectConfiguration>
9+
<ProjectConfiguration Include="Debug|Win32">
10+
<Configuration>Debug</Configuration>
11+
<Platform>Win32</Platform>
12+
</ProjectConfiguration>
13+
<ProjectConfiguration Include="Debug|x64">
14+
<Configuration>Debug</Configuration>
15+
<Platform>x64</Platform>
16+
</ProjectConfiguration>
17+
<ProjectConfiguration Include="Release|ARM">
18+
<Configuration>Release</Configuration>
19+
<Platform>ARM</Platform>
20+
</ProjectConfiguration>
21+
<ProjectConfiguration Include="Release|Win32">
22+
<Configuration>Release</Configuration>
23+
<Platform>Win32</Platform>
24+
</ProjectConfiguration>
25+
<ProjectConfiguration Include="Release|x64">
26+
<Configuration>Release</Configuration>
27+
<Platform>x64</Platform>
28+
</ProjectConfiguration>
29+
</ItemGroup>
30+
<PropertyGroup Label="Globals">
31+
<ProjectGuid>{47A5CFDC-C244-45A6-9830-38CB303CB495}</ProjectGuid>
32+
<Keyword>StaticLibrary</Keyword>
33+
<DefaultLanguage>en-US</DefaultLanguage>
34+
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
35+
<AppContainerApplication>true</AppContainerApplication>
36+
<ApplicationType>Windows Store</ApplicationType>
37+
<ApplicationTypeRevision>8.2</ApplicationTypeRevision>
38+
<ProjectName>cpprestsdk140.uwp.staticlib</ProjectName>
39+
<PlatformToolset>v140</PlatformToolset>
40+
<ConfigurationType>StaticLibrary</ConfigurationType>
41+
<OutDir>$(OutDir)\$(MsBuildProjectName)</OutDir>
42+
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
43+
<WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>
44+
</PropertyGroup>
45+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
46+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
47+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))\Build\Config.Definitions.props" />
48+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.root))\Build\Release.Product.Settings" />
49+
<ImportGroup Label="ExtensionSettings">
50+
</ImportGroup>
51+
<ImportGroup Label="Shared">
52+
<Import Project="..\common.vcxitems" Label="Shared" />
53+
<Import Project="..\winrt.vcxitems" Label="Shared" />
54+
</ImportGroup>
55+
<ImportGroup Label="PropertySheets">
56+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+
</ImportGroup>
58+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
59+
<DebugFileSuffix>d</DebugFileSuffix>
60+
</PropertyGroup>
61+
<PropertyGroup>
62+
<TargetName>lib$(CppRestBaseFileName)140$(DebugFileSuffix)_uwp_$(CppRestSDKVersionFileSuffix)</TargetName>
63+
</PropertyGroup>
64+
<PropertyGroup Label="UserMacros" />
65+
<PropertyGroup />
66+
<PropertyGroup>
67+
<GenerateManifest>false</GenerateManifest>
68+
<IgnoreImportLibrary>false</IgnoreImportLibrary>
69+
</PropertyGroup>
70+
<ItemDefinitionGroup>
71+
<ClCompile>
72+
<PreprocessorDefinitions>_NO_ASYNCRTIMP;_NO_PPLXIMP;_USRDLL;%(PreprocessorDefinitions);</PreprocessorDefinitions>
73+
<PrecompiledHeader>Use</PrecompiledHeader>
74+
<CompileAsWinRT>true</CompileAsWinRT>
75+
<AdditionalIncludeDirectories>$(CasablancaIncludeDir);$(CasablancaSrcDir)\pch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
76+
<PrecompiledHeader>Use</PrecompiledHeader>
77+
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
78+
<AdditionalOptions>-Zm250 /bigobj %(AdditionalOptions)</AdditionalOptions>
79+
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
80+
</ClCompile>
81+
<Link>
82+
<SubSystem>Console</SubSystem>
83+
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
84+
<LinkTimeCodeGeneration Condition="'$(Configuration)'=='Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
85+
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
86+
</Link>
87+
</ItemDefinitionGroup>
88+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
89+
<ItemDefinitionGroup>
90+
<PostBuildEvent>
91+
<Command>copy /Y $(OutDir)\* $(OutDir)..\
92+
exit 0</Command>
93+
<Message>Copying $(TargetName).winrt binaries to OutDir and removing appcontainer flag</Message>
94+
</PostBuildEvent>
95+
<Lib>
96+
<TargetMachine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MachineX86</TargetMachine>
97+
</Lib>
98+
<Lib>
99+
<TargetMachine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MachineX86</TargetMachine>
100+
</Lib>
101+
<Lib>
102+
<TargetMachine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MachineX64</TargetMachine>
103+
</Lib>
104+
<Lib>
105+
<TargetMachine Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MachineX64</TargetMachine>
106+
</Lib>
107+
</ItemDefinitionGroup>
108+
<ImportGroup Label="ExtensionTargets">
109+
</ImportGroup>
110+
</Project>

Release/src/http/listener/http_listener_msg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pplx::task<void> details::_http_request::_reply_impl(http_response response)
4747
{
4848
// Add a task-based continuation so no exceptions thrown from the task go 'unobserved'.
4949
response._set_server_context(std::move(m_server_context));
50-
response_completed = experimental::details::http_server_api::server_api()->respond(response);
50+
response_completed = server_api->respond(response);
5151
response_completed.then([](pplx::task<void> t)
5252
{
5353
try { t.wait(); } catch(...) {}

0 commit comments

Comments
 (0)