From 06aeb8ea9f60d474ce64bc2004433c17a4ce6b78 Mon Sep 17 00:00:00 2001 From: dejaniv Date: Thu, 11 Jul 2019 18:15:21 -0700 Subject: [PATCH 01/13] Fix issue #1171: Order of object destruction (#1175) - Connection object is now destroyed before client object - Client is destroyed only when wspp_callback_client is destroyed to prevent race condition with the destructor --- Release/src/websockets/client/ws_client_wspp.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Release/src/websockets/client/ws_client_wspp.cpp b/Release/src/websockets/client/ws_client_wspp.cpp index 5ef74aaf1e..26fa547d5d 100644 --- a/Release/src/websockets/client/ws_client_wspp.cpp +++ b/Release/src/websockets/client/ws_client_wspp.cpp @@ -689,9 +689,6 @@ class wspp_callback_client : public websocket_client_callback_impl, } } // unlock - // Delete client to make sure Websocketpp cleans up all Boost.Asio portions. - m_client.reset(); - if (connecting) { websocket_exception exc(ec, build_error_msg(ec, "set_fail_handler")); @@ -801,8 +798,6 @@ class wspp_callback_client : public websocket_client_callback_impl, websocketpp::client m_client; }; - websocketpp::connection_hdl m_con; - pplx::task_completion_event m_connect_tce; pplx::task_completion_event m_close_tce; @@ -810,6 +805,7 @@ class wspp_callback_client : public websocket_client_callback_impl, std::mutex m_wspp_client_lock; State m_state; std::unique_ptr m_client; + websocketpp::connection_hdl m_con; // Queue to track pending sends outgoing_msg_queue m_out_queue; From 47cd408966f33199903a6b1426ce843235873084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Meusel?= Date: Fri, 12 Jul 2019 03:16:57 +0200 Subject: [PATCH 02/13] FIX: SSL proxy tunnel support with basic auth (#1183) --- Release/src/http/client/http_client_asio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 96a627abe2..c5c815eec7 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -570,7 +570,7 @@ class asio_context final : public request_context, public std::enable_shared_fro if (m_context->m_http_client->client_config().proxy().credentials().is_set()) { - request_stream << m_context->generate_basic_proxy_auth_header() << CRLF; + request_stream << m_context->generate_basic_proxy_auth_header(); } request_stream << CRLF; From 951e269923c7b09a45582e37687124db651f3a34 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Thu, 11 Jul 2019 18:59:47 -0700 Subject: [PATCH 03/13] Fix profile being set on the compiler instead of the linker. (#1184) --- Release/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index c689205590..9a0bbf1a24 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -178,10 +178,13 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4264") add_compile_options(/bigobj) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /profile /OPT:REF /OPT:ICF") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /profile /OPT:REF /OPT:ICF") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP") + set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /profile /OPT:REF /OPT:ICF") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /profile /OPT:REF /OPT:ICF") + if (WINDOWS_STORE OR WINDOWS_PHONE) add_compile_options(/ZW) endif() From 643dc60703987d15b30124ec7ce90d97997f512b Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Fri, 12 Jul 2019 13:14:55 -0700 Subject: [PATCH 04/13] Update boost-for-android for Android NDK r20 and disable macOS Homebrew. (#1185) * Update boost-for-android for Android NDK r20. * Also disable homebrew. * I mean homebrew I said! * Apparently Android isn't ready for Boost 1.70 yet. --- Build_android/configure.sh | 2 +- azure-pipelines.yml | 87 +++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Build_android/configure.sh b/Build_android/configure.sh index b4e3e1748d..5088f44d8f 100755 --- a/Build_android/configure.sh +++ b/Build_android/configure.sh @@ -155,7 +155,7 @@ if [ "${DO_OPENSSL}" == "1" ]; then ( if [ "${DO_BOOST}" == "1" ]; then ( if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi cd Boost-for-Android - git checkout b1e2cb397d3ec573f1cfdf4f4d965766204c53f1 + git checkout aed656a97fb3af7322fd2c3da5995a2d09d87d4b PATH="$PATH:$NDK_DIR" \ CXXFLAGS="-std=gnu++11" \ ./build-android.sh \ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 48d30a1ab8..8c878f0901 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -222,49 +222,50 @@ jobs: export NCPU=2 ../configure.sh --ndk /usr/local/lib/android/sdk/ndk-bundle displayName: 'Build for Android' - - job: MacOS_Homebrew - pool: - vmImage: 'macOS-10.14' - steps: - - script: brew install boost openssl ninja - displayName: Brew install dependencies - - script: | - mkdir build.debug - mkdir build.release - mkdir build.release.static - displayName: Make Build Directories - - task: CMake@1 - inputs: - workingDirectory: 'build.debug' - cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Debug ..' - - task: CMake@1 - inputs: - workingDirectory: 'build.release' - cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release ..' - - task: CMake@1 - inputs: - workingDirectory: 'build.release.static' - cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..' - - script: | - cd build.debug - ninja - displayName: 'Run ninja, debug' - - script: | - cd build.debug/Release/Binaries - ./test_runner *test.dylib - displayName: 'Run tests, debug' - - script: | - cd build.release - ninja - displayName: 'Run ninja, release' - - script: | - cd build.release/Release/Binaries - ./test_runner *test.dylib - displayName: 'Run tests, release' - - script: | - cd build.release.static - ninja - displayName: 'Run ninja, release static' + # Homebrew is disabled for now because it apparently is deploying a Boost version that the version of xcode deployed in Pipelines cannot build. + # - job: MacOS_Homebrew + # pool: + # vmImage: 'macOS-10.14' + # steps: + # - script: brew install boost openssl ninja + # displayName: Brew install dependencies + # - script: | + # mkdir build.debug + # mkdir build.release + # mkdir build.release.static + # displayName: Make Build Directories + # - task: CMake@1 + # inputs: + # workingDirectory: 'build.debug' + # cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Debug ..' + # - task: CMake@1 + # inputs: + # workingDirectory: 'build.release' + # cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release ..' + # - task: CMake@1 + # inputs: + # workingDirectory: 'build.release.static' + # cmakeArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..' + # - script: | + # cd build.debug + # ninja + # displayName: 'Run ninja, debug' + # - script: | + # cd build.debug/Release/Binaries + # ./test_runner *test.dylib + # displayName: 'Run tests, debug' + # - script: | + # cd build.release + # ninja + # displayName: 'Run ninja, release' + # - script: | + # cd build.release/Release/Binaries + # ./test_runner *test.dylib + # displayName: 'Run tests, release' + # - script: | + # cd build.release.static + # ninja + # displayName: 'Run ninja, release static' - job: MacOS_Vcpkg pool: vmImage: 'macOS-10.14' From a718c5bcf471d7589c5779e6746290743cd0f211 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Fri, 12 Jul 2019 16:27:44 -0700 Subject: [PATCH 05/13] Remove invalid nondependent static assert (#1186) * Remove invalid static_assert(false). * Turn on permissive-. * clang-format --- Release/CMakeLists.txt | 4 ++++ Release/include/cpprest/streams.h | 18 ++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index 9a0bbf1a24..b9e6d6d56a 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -188,6 +188,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if (WINDOWS_STORE OR WINDOWS_PHONE) add_compile_options(/ZW) endif() + + if (NOT (MSVC_VERSION LESS 1920)) + add_compile_options(/permissive-) + endif() else() message("-- Unknown compiler, success is doubtful.") message("CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}") diff --git a/Release/include/cpprest/streams.h b/Release/include/cpprest/streams.h index bfeeee5885..08713226b7 100644 --- a/Release/include/cpprest/streams.h +++ b/Release/include/cpprest/streams.h @@ -528,9 +528,12 @@ class type_parser public: static pplx::task parse(streams::streambuf buffer) { - typename _type_parser_integral_traits::_is_integral ii; - typename _type_parser_integral_traits::_is_unsigned ui; - return _parse(buffer, ii, ui); + typedef typename _type_parser_integral_traits::_is_integral ii; + typedef typename _type_parser_integral_traits::_is_unsigned ui; + + static_assert(ii::value || !ui::value, "type is not supported for extraction from a stream"); + + return _parse(buffer, ii {}, ui {}); } private: @@ -539,15 +542,6 @@ class type_parser _parse_floating_point(buffer); } - static pplx::task _parse(streams::streambuf, std::false_type, std::true_type) - { -#ifdef _WIN32 - static_assert(false, "type is not supported for extraction from a stream"); -#else - throw std::runtime_error("type is not supported for extraction from a stream"); -#endif - } - static pplx::task _parse(streams::streambuf buffer, std::true_type, std::false_type) { return type_parser::parse(buffer).then([](pplx::task op) -> T { From bed8fa538c862a8297cb02c99d8b3dcc29247d5b Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Fri, 12 Jul 2019 18:05:14 -0700 Subject: [PATCH 06/13] Replace CPPREST_TARGET_XP with version checks, remove ""s, and other cleanup (#1187) * Audit for "" and use std::string default ctor instead. * Fix Linux ambiguity. * Exclude common build directories. * Replace CPPREST_TARGET_XP with checks against _WIN32_WINNT to allow more fine grained controls going forward (e.g. assume Win10). Also fix a few typos. * Delete CASABLANCA_UNREFERENCED_PARAMETER and attempt Linux compile fix. * Defend NOMINMAX. * Another _WIN32 guard. * With && this time. * Fix more spelling errors. * Optimize trim_nulls slightly. * And actually make the optimization correct this time. * Fix unit test failure. * clang-format --- .gitignore | 2 + .vscode/settings.json | 16 ++- .../include/cpprest/details/cpprest_compat.h | 3 - .../include/cpprest/details/web_utilities.h | 30 ++-- Release/include/cpprest/http_client.h | 6 +- Release/include/cpprest/streams.h | 21 ++- Release/include/cpprest/ws_client.h | 7 +- Release/include/cpprest/ws_msg.h | 2 +- Release/include/pplx/pplxtasks.h | 4 +- .../BlackJack_Client/BlackJackClient.cpp | 1 - .../BlackJack/BlackJack_Server/messagetypes.h | 4 +- .../BlackJack/BlackJack_Server/stdafx.h | 3 - .../BlackJack_UIClient/Player.xaml.cpp | 16 ++- .../BlackJack_UIClient/Player.xaml.h | 8 +- .../BlackJack_UIClient/PlayingTable.xaml.cpp | 22 +-- .../BlackJack_UIClient/PlayingTable.xaml.h | 2 +- Release/samples/CasaLens/casalens.cpp | 8 +- Release/samples/OAuth2Live/MainPage.xaml.cpp | 6 +- Release/samples/Oauth1Client/Oauth1Client.cpp | 8 +- Release/samples/Oauth2Client/Oauth2Client.cpp | 14 +- .../samples/WindowsLiveAuth/live_connect.h | 4 +- Release/src/http/client/http_client.cpp | 2 +- Release/src/http/client/http_client_asio.cpp | 26 ++-- .../src/http/client/http_client_winhttp.cpp | 130 +++++++++++------- Release/src/http/client/http_client_winrt.cpp | 18 +-- Release/src/http/common/http_compression.cpp | 4 +- Release/src/http/common/http_msg.cpp | 16 +-- .../src/http/listener/http_server_asio.cpp | 16 +-- .../src/http/listener/http_server_httpsys.cpp | 8 +- .../src/http/listener/http_server_httpsys.h | 6 +- Release/src/http/oauth/oauth1.cpp | 4 +- Release/src/json/json.cpp | 11 +- Release/src/pch/stdafx.h | 24 ++-- Release/src/streams/fileio_posix.cpp | 8 +- Release/src/streams/fileio_win32.cpp | 6 +- Release/src/uri/uri.cpp | 2 +- Release/src/utilities/web_utilities.cpp | 16 ++- Release/src/websockets/client/ws_client.cpp | 3 +- .../src/websockets/client/ws_client_winrt.cpp | 2 +- .../src/websockets/client/ws_client_wspp.cpp | 47 ++++--- .../tests/common/TestRunner/test_runner.cpp | 6 +- Release/tests/common/UnitTestpp/src/Checks.h | 2 +- .../UnitTestpp/src/DeferredTestResult.cpp | 6 +- .../common/UnitTestpp/src/MemoryOutStream.cpp | 2 +- Release/tests/common/UnitTestpp/src/stdafx.h | 1 - .../tests/common/utilities/os_utilities.cpp | 1 - .../http/client/compression_tests.cpp | 22 +-- .../functional/http/client/outside_tests.cpp | 2 +- .../tests/functional/http/utilities/stdafx.h | 1 - .../functional/json/json_numbers_tests.cpp | 16 +-- Release/tests/functional/json/stdafx.h | 1 - .../misc/atl_headers/header_test1.cpp | 1 - .../misc/atl_headers/header_test2.cpp | 1 - .../tests/functional/pplx/pplx_test/stdafx.h | 1 - .../functional/streams/istream_tests.cpp | 2 +- .../functional/streams/memstream_tests.cpp | 1 - .../utils/win32_encryption_tests.cpp | 4 +- .../functional/websockets/utilities/stdafx.h | 1 - 58 files changed, 326 insertions(+), 281 deletions(-) diff --git a/.gitignore b/.gitignore index 8fc8285e16..3a3fea4411 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,5 @@ Build_android/build/ Generated Files/ # Ignore iOS temp build directories Build_iOS/Apple-Boost-BuildScript + +/out/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 2fc5e0c5fe..9bad9cb7c7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,18 @@ "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, "**/node_modules/*/**": true, - "**/vcpkg/**": true - } + "**/vcpkg/**": true, + "build.x86.debug": true, + "build.x86.release": true, + "build.x64.debug": true, + "build.x64.release": true, + "out": true, + }, + "cSpell.words": [ + "XPLATSTR", + "blittable", + "pplx", + "rdpos", + "rgpsz" + ] } diff --git a/Release/include/cpprest/details/cpprest_compat.h b/Release/include/cpprest/details/cpprest_compat.h index c671ce2fe5..6dae41d8d9 100644 --- a/Release/include/cpprest/details/cpprest_compat.h +++ b/Release/include/cpprest/details/cpprest_compat.h @@ -24,8 +24,6 @@ #define CPPREST_CONSTEXPR const #endif // _MSC_VER >= 1900 -#define CASABLANCA_UNREFERENCED_PARAMETER(x) (x) - #include #else // ^^^ _WIN32 ^^^ // vvv !_WIN32 vvv @@ -38,7 +36,6 @@ { \ if (!(x)) __builtin_unreachable(); \ } while (false) -#define CASABLANCA_UNREFERENCED_PARAMETER(x) (void)x #define CPPREST_NOEXCEPT noexcept #define CPPREST_CONSTEXPR constexpr diff --git a/Release/include/cpprest/details/web_utilities.h b/Release/include/cpprest/details/web_utilities.h index 8b99d94aa2..aed7419c85 100644 --- a/Release/include/cpprest/details/web_utilities.h +++ b/Release/include/cpprest/details/web_utilities.h @@ -10,6 +10,10 @@ ****/ #pragma once +#ifdef _WIN32 +#include +#endif // _WIN32 + #include "cpprest/asyncrt_utils.h" #include "cpprest/uri.h" @@ -24,23 +28,24 @@ class zero_memory_deleter }; typedef std::unique_ptr<::utility::string_t, zero_memory_deleter> plaintext_string; -#if defined(_WIN32) && !defined(CPPREST_TARGET_XP) -#if defined(__cplusplus_winrt) +#ifdef _WIN32 +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA +#ifdef __cplusplus_winrt class winrt_encryption { public: - winrt_encryption() {} + winrt_encryption() = default; _ASYNCRTIMP winrt_encryption(const std::wstring& data); _ASYNCRTIMP plaintext_string decrypt() const; private: ::pplx::task m_buffer; }; -#else +#else // ^^^ __cplusplus_winrt ^^^ // vvv !__cplusplus_winrt vvv class win32_encryption { public: - win32_encryption() {} + win32_encryption() = default; _ASYNCRTIMP win32_encryption(const std::wstring& data); _ASYNCRTIMP ~win32_encryption(); _ASYNCRTIMP plaintext_string decrypt() const; @@ -49,8 +54,9 @@ class win32_encryption std::vector m_buffer; size_t m_numCharacters; }; -#endif -#endif +#endif // __cplusplus_winrt +#endif // _WIN32_WINNT >= _WIN32_WINNT_VISTA +#endif // _WIN32 } // namespace details /// @@ -89,7 +95,7 @@ class credentials "This API is deprecated for security reasons to avoid unnecessary password copies stored in plaintext.") utility::string_t password() const { -#if defined(_WIN32) && !defined(CPPREST_TARGET_XP) +#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA return utility::string_t(*m_password.decrypt()); #else return m_password; @@ -105,7 +111,7 @@ class credentials details::plaintext_string _internal_decrypt() const { // Encryption APIs not supported on XP -#if defined(_WIN32) && !defined(CPPREST_TARGET_XP) +#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA return m_password.decrypt(); #else return details::plaintext_string(new ::utility::string_t(m_password)); @@ -115,7 +121,7 @@ class credentials private: ::utility::string_t m_username; -#if defined(_WIN32) && !defined(CPPREST_TARGET_XP) +#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA #if defined(__cplusplus_winrt) details::winrt_encryption m_password; #else @@ -151,13 +157,13 @@ class web_proxy /// /// Constructs a proxy with the default settings. /// - web_proxy() : m_address(_XPLATSTR("")), m_mode(use_default_) {} + web_proxy() : m_address(), m_mode(use_default_) {} /// /// Creates a proxy with specified mode. /// /// Mode to use. - web_proxy(web_proxy_mode mode) : m_address(_XPLATSTR("")), m_mode(static_cast(mode)) {} + web_proxy(web_proxy_mode mode) : m_address(), m_mode(static_cast(mode)) {} /// /// Creates a proxy explicitly with provided address. diff --git a/Release/include/cpprest/http_client.h b/Release/include/cpprest/http_client.h index 743e2b5635..0bedfbd42a 100644 --- a/Release/include/cpprest/http_client.h +++ b/Release/include/cpprest/http_client.h @@ -54,7 +54,7 @@ typedef void* native_handle; #include #include -#if !defined(CPPREST_TARGET_XP) +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA #include "cpprest/oauth1.h" #endif @@ -110,7 +110,7 @@ class http_client_config { } -#if !defined(CPPREST_TARGET_XP) +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA /// /// Get OAuth 1.0 configuration. /// @@ -363,7 +363,7 @@ class http_client_config #endif private: -#if !defined(CPPREST_TARGET_XP) +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA std::shared_ptr m_oauth1; #endif diff --git a/Release/include/cpprest/streams.h b/Release/include/cpprest/streams.h index 08713226b7..c2968b9d49 100644 --- a/Release/include/cpprest/streams.h +++ b/Release/include/cpprest/streams.h @@ -470,7 +470,7 @@ _UINT_TRAIT(unsigned long long, ULLONG_MIN, ULLONG_MAX) { \ typedef std::true_type _is_integral; \ typedef std::false_type _is_unsigned; \ - static const int64_t _min = std::numeric_limits<_t>::min(); \ + static const int64_t _min = (std::numeric_limits<_t>::min)(); \ static const int64_t _max = (std::numeric_limits<_t>::max)(); \ }; #define _UINT_TRAIT(_t) \ @@ -1139,8 +1139,8 @@ pplx::task _type_parser_base::_parse_input(concurrency::st auto update = [=](pplx::task op) -> pplx::task { int_type ch = op.get(); if (ch == traits::eof()) return pplx::task_from_result(false); - bool accptd = accept_character(state, ch); - if (!accptd) return pplx::task_from_result(false); + bool accepted = accept_character(state, ch); + if (!accepted) return pplx::task_from_result(false); // We peeked earlier, so now we must advance the position. concurrency::streams::streambuf buf = buffer; return buf.bumpc().then([](int_type) { return true; }); @@ -1308,9 +1308,18 @@ struct _double_state template static std::string create_exception_message(int_type ch, bool exponent) { - std::ostringstream os; - os << "Invalid character '" << char(ch) << "'" << (exponent ? " in exponent" : ""); - return os.str(); + std::string result; + if (exponent) + { + result.assign("Invalid character 'X' in exponent"); + } + else + { + result.assign("Invalid character 'X'"); + } + + result[19] = static_cast(ch); + return result; } template diff --git a/Release/include/cpprest/ws_client.h b/Release/include/cpprest/ws_client.h index 9c202d7f73..af17bd6060 100644 --- a/Release/include/cpprest/ws_client.h +++ b/Release/include/cpprest/ws_client.h @@ -330,8 +330,7 @@ class websocket_client_callback_impl virtual pplx::task close() = 0; - virtual pplx::task close(websocket_close_status close_status, - const utility::string_t& close_reason = _XPLATSTR("")) = 0; + virtual pplx::task close(websocket_close_status close_status, const utility::string_t& close_reason = {}) = 0; virtual void set_close_handler( const std::function& @@ -478,7 +477,7 @@ class websocket_client /// frame. While closing an established connection, an endpoint may indicate the /// reason for closure. An asynchronous operation that is completed the connection has been /// successfully closed. - pplx::task close(websocket_close_status close_status, const utility::string_t& close_reason = _XPLATSTR("")) + pplx::task close(websocket_close_status close_status, const utility::string_t& close_reason = {}) { return m_client->callback_client()->close(close_status, close_reason); } @@ -566,7 +565,7 @@ class websocket_callback_client /// frame. While closing an established connection, an endpoint may indicate the /// reason for closure. An asynchronous operation that is completed the connection has been /// successfully closed. - pplx::task close(websocket_close_status close_status, const utility::string_t& close_reason = _XPLATSTR("")) + pplx::task close(websocket_close_status close_status, const utility::string_t& close_reason = {}) { return m_client->close(close_status, close_reason); } diff --git a/Release/include/cpprest/ws_msg.h b/Release/include/cpprest/ws_msg.h index 73e968a001..9b13a80849 100644 --- a/Release/include/cpprest/ws_msg.h +++ b/Release/include/cpprest/ws_msg.h @@ -74,7 +74,7 @@ class websocket_outgoing_message /// /// UTF-8 String containing the optional pong message. void set_pong_message(const std::string& data = {}) - { + { this->set_message_pong(concurrency::streams::container_buffer(data)); } #endif diff --git a/Release/include/pplx/pplxtasks.h b/Release/include/pplx/pplxtasks.h index 63cedc4f28..6868fc1619 100644 --- a/Release/include/pplx/pplxtasks.h +++ b/Release/include/pplx/pplxtasks.h @@ -3799,7 +3799,7 @@ class task auto _LogWorkItemAndInvokeUserLambda(_Func&& _func) const -> decltype(_func()) { details::_TaskWorkItemRAIILogger _LogWorkItem(this->_M_pTask->_M_taskEventLogger); - CASABLANCA_UNREFERENCED_PARAMETER(_LogWorkItem); + (void)_LogWorkItem; return _func(); } @@ -3931,7 +3931,7 @@ class task -> decltype(_func(std::forward<_Arg>(_value))) { details::_TaskWorkItemRAIILogger _LogWorkItem(this->_M_pTask->_M_taskEventLogger); - CASABLANCA_UNREFERENCED_PARAMETER(_LogWorkItem); + (void)_LogWorkItem; return _func(std::forward<_Arg>(_value)); } diff --git a/Release/samples/BlackJack/BlackJack_Client/BlackJackClient.cpp b/Release/samples/BlackJack/BlackJack_Client/BlackJackClient.cpp index 5c9b1fc4b1..184ab42937 100644 --- a/Release/samples/BlackJack/BlackJack_Client/BlackJackClient.cpp +++ b/Release/samples/BlackJack/BlackJack_Client/BlackJackClient.cpp @@ -17,7 +17,6 @@ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#define NOMINMAX #include #include diff --git a/Release/samples/BlackJack/BlackJack_Server/messagetypes.h b/Release/samples/BlackJack/BlackJack_Server/messagetypes.h index 91c633984e..f38556dde3 100644 --- a/Release/samples/BlackJack/BlackJack_Server/messagetypes.h +++ b/Release/samples/BlackJack/BlackJack_Server/messagetypes.h @@ -179,7 +179,7 @@ struct BJHand { if (iter->value == CV_Ace) hasAces = true; - res.low += std::min((int)iter->value, 10); + res.low += (std::min)((int)iter->value, 10); } res.high = hasAces ? res.low + 10 : res.low; return res; @@ -271,7 +271,7 @@ struct Player static Player FromJSON(const web::json::object& object) { - Player result(U("")); + Player result(utility::string_t{}); auto iName = object.find(NAME); if (iName == object.end()) diff --git a/Release/samples/BlackJack/BlackJack_Server/stdafx.h b/Release/samples/BlackJack/BlackJack_Server/stdafx.h index ae59ac7dbd..d9bef583ff 100644 --- a/Release/samples/BlackJack/BlackJack_Server/stdafx.h +++ b/Release/samples/BlackJack/BlackJack_Server/stdafx.h @@ -26,9 +26,6 @@ #include #ifdef _WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #else #include diff --git a/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.cpp b/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.cpp index e32a766883..394165a53c 100644 --- a/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.cpp +++ b/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.cpp @@ -54,7 +54,13 @@ void PlayerSpace::Update(Player player) playerName->Text = ref new Platform::String(web::uri::decode(player.Name).c_str()); playerBalance->Text = "$" + player.Balance.ToString(); playerBet->Text = "Bet: $" + player.Hand.bet.ToString(); - playerInsurance->Text = (player.Hand.insurance > 0) ? "Ins: $" + player.Hand.insurance.ToString() : ""; + if (player.Hand.insurance > 0) { + auto& text = playerInsurance->Text; + text.assign("Ins: $"); + text.append(std::to_string(player.Hand.insurance)); + } else { + text.clear(); + } } void PlayerSpace::AddCard(Card card) @@ -87,19 +93,19 @@ void PlayerSpace::ShowResult(BJHandResult result) { case BJHandResult::HR_ComputerWin: playerInsurance->Text = L"Dealer Wins"; - playerBet->Text = L""; + playerBet->Text.clear(); break; case BJHandResult::HR_PlayerWin: playerInsurance->Text = L"Player Wins"; - playerBet->Text = L""; + playerBet->Text.clear(); break; case BJHandResult::HR_Push: playerInsurance->Text = L"Push"; - playerBet->Text = L""; + playerBet->Text.clear(); break; case BJHandResult::HR_PlayerBlackJack: playerInsurance->Text = L"Blackjack!"; - playerBet->Text = L""; + playerBet->Text.clear(); break; default: break; } diff --git a/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.h b/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.h index 429d5e38c3..5b7ee7462b 100644 --- a/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.h +++ b/Release/samples/BlackJack/BlackJack_UIClient/Player.xaml.h @@ -25,10 +25,10 @@ ref class PlayerSpace sealed void Clear() { - playerBalance->Text = L""; - playerBet->Text = L""; - playerName->Text = L""; - playerInsurance->Text = L""; + playerBalance->Text.clear(); + playerBet->Text.clear(); + playerName->Text.clear(); + playerInsurance->Text.clear(); m_cards.clear(); playerCardGrid->Children->Clear(); } diff --git a/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.cpp b/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.cpp index 64fd0adae6..5f835e1b3f 100644 --- a/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.cpp +++ b/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.cpp @@ -116,7 +116,7 @@ void BlackjackClient::PlayingTable::Refresh() request.then( [this](pplx::task tsk) { - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -137,7 +137,7 @@ void BlackjackClient::PlayingTable::InterpretResponse(http_response& response) { if (response.headers().content_type() != L"application/json") return; - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); response.extract_json().then( [this, response](json::value jsonResponse) { @@ -265,7 +265,7 @@ void BlackjackClient::PlayingTable::BetButton_Click(Platform::Object ^ sender, request.then( [this](pplx::task tsk) { - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -307,7 +307,7 @@ void BlackjackClient::PlayingTable::InsuranceButton_Click(Platform::Object ^ sen request.then( [this](pplx::task tsk) { - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -343,7 +343,7 @@ void BlackjackClient::PlayingTable::DoubleButton_Click(Platform::Object ^ sender request.then( [this](pplx::task tsk) { - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -378,7 +378,7 @@ void BlackjackClient::PlayingTable::StayButton_Click(Platform::Object ^ sender, request.then( [this](pplx::task tsk) { - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -412,7 +412,7 @@ void BlackjackClient::PlayingTable::HitButton_Click(Platform::Object ^ sender, request.then( [this](pplx::task tsk) { - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -449,7 +449,7 @@ void BlackjackClient::PlayingTable::ExitButton_Click(Platform::Object ^ sender, [this](pplx::task tsk) { EnableExit(); - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -499,7 +499,7 @@ void BlackjackClient::PlayingTable::JoinButton_Click(Platform::Object ^ sender, [this](pplx::task tsk) { EnableExit(); - this->resultLabel->Text = L""; + this->resultLabel->Text.clear(); try { @@ -516,7 +516,7 @@ void BlackjackClient::PlayingTable::JoinButton_Click(Platform::Object ^ sender, { InterpretError(exc.error_code().value()); EnableConnecting(); - _tableId = L""; + _tableId.clear(); } }, ctx); @@ -551,7 +551,7 @@ void BlackjackClient::PlayingTable::LeaveButton_Click(Platform::Object ^ sender, this->resultLabel->Text = L"Thanks for playing!"; - _tableId = L""; + _tableId.clear(); } catch (const http_exception& exc) { diff --git a/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.h b/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.h index 589c1f9e6c..9f2fbe689a 100644 --- a/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.h +++ b/Release/samples/BlackJack/BlackJack_UIClient/PlayingTable.xaml.h @@ -93,7 +93,7 @@ ref class PlayingTable sealed { ClearDealerCards(); ClearPlayerCards(); - resultLabel->Text = ""; + resultLabel->Text.clear(); } void EnableBetting() diff --git a/Release/samples/CasaLens/casalens.cpp b/Release/samples/CasaLens/casalens.cpp index c98e926abf..5990ef240f 100644 --- a/Release/samples/CasaLens/casalens.cpp +++ b/Release/samples/CasaLens/casalens.cpp @@ -30,13 +30,13 @@ const utility::string_t casalens_creds::weather_url = U("http://api.openweatherm // FILL IN THE API KEYS FOR THE DIFFERENT SERVICES HERE. // Refer Readme.txt for details on how to obtain the key for the services. const utility::string_t casalens_creds::events_keyname = U("app_key"); -const utility::string_t casalens_creds::events_key = U(""); +const utility::string_t casalens_creds::events_key; const utility::string_t casalens_creds::movies_keyname = U("api_key"); -const utility::string_t casalens_creds::movies_key = U(""); +const utility::string_t casalens_creds::movies_key; const utility::string_t casalens_creds::images_keyname = U("username"); -const utility::string_t casalens_creds::images_key = U(""); +const utility::string_t casalens_creds::images_key; const utility::string_t casalens_creds::bmaps_keyname = U("key"); -const utility::string_t casalens_creds::bmaps_key = U(""); +const utility::string_t casalens_creds::bmaps_key; const utility::string_t CasaLens::events_json_key = U("events"); const utility::string_t CasaLens::movies_json_key = U("movies"); diff --git a/Release/samples/OAuth2Live/MainPage.xaml.cpp b/Release/samples/OAuth2Live/MainPage.xaml.cpp index acdc7ba4e3..fef5d2d365 100644 --- a/Release/samples/OAuth2Live/MainPage.xaml.cpp +++ b/Release/samples/OAuth2Live/MainPage.xaml.cpp @@ -29,8 +29,8 @@ using namespace web::http::oauth2::experimental; // // NOTE: You must set this Live key and secret for app to work. // -static const utility::string_t s_live_key(U("")); -static const utility::string_t s_live_secret(U("")); +static const utility::string_t s_live_key; +static const utility::string_t s_live_secret; MainPage::MainPage() : m_live_oauth2_config(s_live_key, @@ -69,7 +69,7 @@ void OAuth2Live::MainPage::_GetToken() // Start over, clear tokens and button state. m_live_oauth2_config.set_token(oauth2_token()); - AccessToken->Text = ""; + AccessToken->Text.clear(); _UpdateButtonState(); String ^ authURI = ref new String(m_live_oauth2_config.build_authorization_uri(true).c_str()); diff --git a/Release/samples/Oauth1Client/Oauth1Client.cpp b/Release/samples/Oauth1Client/Oauth1Client.cpp index da09fda29f..dec9b342b5 100644 --- a/Release/samples/Oauth1Client/Oauth1Client.cpp +++ b/Release/samples/Oauth1Client/Oauth1Client.cpp @@ -49,11 +49,11 @@ using namespace web::http::experimental::listener; // // Set key & secret pair to enable session for that service. // -static const utility::string_t s_linkedin_key(U("")); -static const utility::string_t s_linkedin_secret(U("")); +static const utility::string_t s_linkedin_key; +static const utility::string_t s_linkedin_secret; -static const utility::string_t s_twitter_key(U("")); -static const utility::string_t s_twitter_secret(U("")); +static const utility::string_t s_twitter_key; +static const utility::string_t s_twitter_secret; // // Utility method to open browser on Windows, OS X and Linux systems. diff --git a/Release/samples/Oauth2Client/Oauth2Client.cpp b/Release/samples/Oauth2Client/Oauth2Client.cpp index 2d82a70f18..19072cf6c6 100644 --- a/Release/samples/Oauth2Client/Oauth2Client.cpp +++ b/Release/samples/Oauth2Client/Oauth2Client.cpp @@ -49,14 +49,14 @@ using namespace web::http::experimental::listener; // // Set key & secret pair to enable session for that service. // -static const utility::string_t s_dropbox_key(U("")); -static const utility::string_t s_dropbox_secret(U("")); +static const utility::string_t s_dropbox_key; +static const utility::string_t s_dropbox_secret; -static const utility::string_t s_linkedin_key(U("")); -static const utility::string_t s_linkedin_secret(U("")); +static const utility::string_t s_linkedin_key; +static const utility::string_t s_linkedin_secret; -static const utility::string_t s_live_key(U("")); -static const utility::string_t s_live_secret(U("")); +static const utility::string_t s_live_key; +static const utility::string_t s_live_secret; // // Utility method to open browser on Windows, OS X and Linux systems. @@ -89,7 +89,7 @@ class oauth2_code_listener : m_listener(new http_listener(listen_uri)), m_config(config) { m_listener->support([this](http::http_request request) -> void { - if (request.request_uri().path() == U("/") && request.request_uri().query() != U("")) + if (request.request_uri().path() == U("/") && !request.request_uri().query().empty()) { m_resplock.lock(); diff --git a/Release/samples/WindowsLiveAuth/live_connect.h b/Release/samples/WindowsLiveAuth/live_connect.h index c8381df046..325538c84f 100644 --- a/Release/samples/WindowsLiveAuth/live_connect.h +++ b/Release/samples/WindowsLiveAuth/live_connect.h @@ -338,7 +338,7 @@ class live_client web::http::http_request req(web::http::methods::PUT); req.set_request_uri(bldr.to_string()); - req.set_body(stream, content_length, U("")); + req.set_body(stream, content_length, utility::string_t{}); return _make_request(req).then([](web::http::http_response response) { return _json_extract(response); }); } @@ -368,7 +368,7 @@ class live_client web::http::http_request req(web::http::methods::PUT); req.set_request_uri(bldr.to_string()); - req.set_body(stream, size, U("")); + req.set_body(stream, size, utility::string_t{}); return _make_request(req) .then([](web::http::http_response response) { return response.content_ready(); }) diff --git a/Release/src/http/client/http_client.cpp b/Release/src/http/client/http_client.cpp index 41230ea517..f3174272bb 100644 --- a/Release/src/http/client/http_client.cpp +++ b/Release/src/http/client/http_client.cpp @@ -386,7 +386,7 @@ http_client::http_client(const uri& base_uri, const http_client_config& client_c m_pipeline = std::make_shared(std::move(final_pipeline_stage)); -#if !defined(CPPREST_TARGET_XP) +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA add_handler(std::static_pointer_cast( std::make_shared(client_config.oauth1()))); #endif diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index c5c815eec7..f8401d6e99 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -87,8 +87,7 @@ namespace { const std::string CRLF("\r\n"); -std::string calc_cn_host(const web::http::uri& baseUri, - const web::http::http_headers& requestHeaders) +std::string calc_cn_host(const web::http::uri& baseUri, const web::http::http_headers& requestHeaders) { std::string result; if (baseUri.scheme() == U("https")) @@ -905,7 +904,8 @@ class asio_context final : public request_context, public std::enable_shared_fro } }; - // Note that we must not try to CONNECT using an already established connection via proxy -- this would send CONNECT to the end server which is definitely not what we want. + // Note that we must not try to CONNECT using an already established connection via proxy -- this would send + // CONNECT to the end server which is definitely not what we want. if (proxy_type == http_proxy_type::ssl_tunnel && !m_connection->is_reused()) { // The ssl_tunnel_proxy keeps the context alive and then calls back once the ssl tunnel is established via @@ -1234,8 +1234,8 @@ class asio_context final : public request_context, public std::enable_shared_fro } const auto this_request = shared_from_this(); - const auto readSize = static_cast( - std::min(static_cast(m_http_client->client_config().chunksize()), m_content_length - m_uploaded)); + const auto readSize = static_cast((std::min)( + static_cast(m_http_client->client_config().chunksize()), m_content_length - m_uploaded)); auto readbuf = _get_readbuffer(); readbuf.getn(boost::asio::buffer_cast(m_body_buf.prepare(readSize)), readSize) .then([this_request AND_CAPTURE_MEMBER_FUNCTION_POINTERS](pplx::task op) { @@ -1487,8 +1487,8 @@ class asio_context final : public request_context, public std::enable_shared_fro if (!needChunked) { async_read_until_buffersize( - static_cast( - std::min(m_content_length, static_cast(m_http_client->client_config().chunksize()))), + static_cast((std::min)(m_content_length, + static_cast(m_http_client->client_config().chunksize()))), boost::bind( &asio_context::handle_read_content, shared_from_this(), boost::asio::placeholders::error)); } @@ -1572,7 +1572,7 @@ class asio_context final : public request_context, public std::enable_shared_fro { if (inbytes) { - output.resize(output.size() + std::max(input_size, static_cast(1024))); + output.resize(output.size() + (std::max)(input_size, static_cast(1024))); } got = m_decompressor->decompress(input + inbytes, input_size - inbytes, @@ -1710,7 +1710,7 @@ class asio_context final : public request_context, public std::enable_shared_fro if (ec) { - if (ec == boost::asio::error::eof && m_content_length == std::numeric_limits::max()) + if (ec == boost::asio::error::eof && m_content_length == (std::numeric_limits::max)()) { m_content_length = m_downloaded + m_body_buf.size(); } @@ -1742,7 +1742,7 @@ class asio_context final : public request_context, public std::enable_shared_fro const auto this_request = shared_from_this(); auto read_size = static_cast( - std::min(static_cast(m_body_buf.size()), m_content_length - m_downloaded)); + (std::min)(static_cast(m_body_buf.size()), m_content_length - m_downloaded)); if (m_decompressor) { @@ -1765,7 +1765,7 @@ class asio_context final : public request_context, public std::enable_shared_fro this_request->m_downloaded += static_cast(read_size); this_request->async_read_until_buffersize( - static_cast(std::min( + static_cast((std::min)( static_cast(this_request->m_http_client->client_config().chunksize()), this_request->m_content_length - this_request->m_downloaded)), boost::bind( @@ -1794,7 +1794,7 @@ class asio_context final : public request_context, public std::enable_shared_fro this_request->m_downloaded += static_cast(read_size); this_request->m_body_buf.consume(read_size); this_request->async_read_until_buffersize( - static_cast(std::min( + static_cast((std::min)( static_cast(this_request->m_http_client->client_config().chunksize()), this_request->m_content_length - this_request->m_downloaded)), boost::bind(&asio_context::handle_read_content, @@ -1820,7 +1820,7 @@ class asio_context final : public request_context, public std::enable_shared_fro this_request->m_downloaded += static_cast(writtenSize); this_request->m_body_buf.consume(writtenSize); this_request->async_read_until_buffersize( - static_cast(std::min( + static_cast((std::min)( static_cast(this_request->m_http_client->client_config().chunksize()), this_request->m_content_length - this_request->m_downloaded)), boost::bind(&asio_context::handle_read_content, diff --git a/Release/src/http/client/http_client_winhttp.cpp b/Release/src/http/client/http_client_winhttp.cpp index 61a13abfb5..a6e5a226b1 100644 --- a/Release/src/http/client/http_client_winhttp.cpp +++ b/Release/src/http/client/http_client_winhttp.cpp @@ -20,7 +20,7 @@ #include #include -#ifndef CPPREST_TARGET_XP +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA #include #endif @@ -102,13 +102,46 @@ static http::status_code parse_status_code(HINTERNET request_handle) // Helper function to trim leading and trailing null characters from a string. static void trim_nulls(utility::string_t& str) { - size_t index; - for (index = 0; index < str.size() && str[index] == 0; ++index) - ; - str.erase(0, index); - for (index = str.size(); index > 0 && str[index - 1] == 0; --index) - ; - str.erase(index); + if (str.empty()) + { + return; + } + + auto first = str.begin(); + auto last = str.end(); + + if (*first) + { + --last; + if (*last) + { + // no nulls to remove + return; + } + + // nulls at the back to remove + do + { + --last; + } while (*last == utility::char_t {}); + ++last; + str.erase(last, str.end()); + return; + } + + // nulls at the front, and maybe the back, to remove + first = std::find_if(str.begin(), last, [](const utility::char_t c) { return c != utility::char_t {}; }); + + if (first != last) + { + do + { + --last; + } while (*last == utility::char_t {}); + ++last; + } + + str.assign(first, last); } // Helper function to get the reason phrase from a WinHTTP response. @@ -245,7 +278,7 @@ class winhttp_request_context final : public request_context HINTERNET m_request_handle; std::weak_ptr* - m_request_handle_context; // owned by m_request_handle to be delete'd by WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING + m_request_handle_context; // owned by m_request_handle to be deleted by WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING bool m_proxy_authentication_tried; bool m_server_authentication_tried; @@ -464,7 +497,7 @@ class winhttp_request_context final : public request_context if (m_bytes_remaining) { // We're at the offset of a chunk of consumable data; let the caller process it - l = std::min(m_bytes_remaining, buffer_size - n); + l = (std::min)(m_bytes_remaining, buffer_size - n); m_bytes_remaining -= l; if (!m_bytes_remaining) { @@ -803,12 +836,12 @@ class winhttp_client final : public _http_client_communicator access_type = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY; proxy_name = WINHTTP_NO_PROXY_NAME; -#ifdef CPPREST_TARGET_XP +#if _WIN32_WINNT < _WIN32_WINNT_VISTA if (config.proxy().is_auto_discovery()) { m_proxy_auto_config = true; } -#else // ^^^ CPPREST_TARGET_XP ^^^ // vvv !CPPREST_TARGET_XP vvv +#else // ^^^ _WIN32_WINNT < _WIN32_WINNT_VISTA ^^^ // vvv _WIN32_WINNT >= _WIN32_WINNT_VISTA vvv if (IsWindows8Point1OrGreater()) { // Windows 8.1 and newer supports automatic proxy discovery and auto-fallback to IE proxy settings @@ -854,7 +887,7 @@ class winhttp_client final : public _http_client_communicator m_proxy_auto_config = true; } } -#endif // CPPREST_TARGET_XP +#endif // _WIN32_WINNT < _WIN32_WINNT_VISTA } else { @@ -908,7 +941,7 @@ class winhttp_client final : public _http_client_communicator } // Enable TLS 1.1 and 1.2 -#if !defined(CPPREST_TARGET_XP) +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA BOOL win32_result(FALSE); DWORD secure_protocols(WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 | @@ -1074,11 +1107,11 @@ class winhttp_client final : public _http_client_communicator if (client_config().validate_certificates()) { // if we are validating certificates, also turn on revocation checking - DWORD dwEnableSSLRevocOpt = WINHTTP_ENABLE_SSL_REVOCATION; + DWORD dwEnableSSLRevocationOpt = WINHTTP_ENABLE_SSL_REVOCATION; if (!WinHttpSetOption(winhttp_context->m_request_handle, WINHTTP_OPTION_ENABLE_FEATURE, - &dwEnableSSLRevocOpt, - sizeof(dwEnableSSLRevocOpt))) + &dwEnableSSLRevocationOpt, + sizeof(dwEnableSSLRevocationOpt))) { auto errorCode = GetLastError(); request->report_error(errorCode, build_error_msg(errorCode, "Error enabling SSL revocation check")); @@ -1134,7 +1167,7 @@ class winhttp_client final : public _http_client_communicator } // There is a request body that needs to be transferred. - if (content_length == std::numeric_limits::max()) + if (content_length == (std::numeric_limits::max)()) { // The content length is not set and the application set a stream. This is an // indication that we will use transfer encoding chunked. We still want to @@ -1315,11 +1348,11 @@ class winhttp_client final : public _http_client_communicator chunk_size = p_request_context->m_body_data.size() - http::details::chunked_encoding::additional_encoding_space; } - else if (p_request_context->m_remaining_to_write != std::numeric_limits::max()) + else if (p_request_context->m_remaining_to_write != (std::numeric_limits::max)()) { // Choose a semi-intelligent size based on how much total data is left to compress - chunk_size = std::min(static_cast(p_request_context->m_remaining_to_write) + 128, - p_request_context->m_http_client->client_config().chunksize()); + chunk_size = (std::min)(static_cast(p_request_context->m_remaining_to_write) + 128, + p_request_context->m_http_client->client_config().chunksize()); } else { @@ -1331,8 +1364,8 @@ class winhttp_client final : public _http_client_communicator { // We're not compressing; use the smaller of the remaining data (if known) and the configured (or default) // chunk size - chunk_size = std::min(static_cast(p_request_context->m_remaining_to_write), - p_request_context->m_http_client->client_config().chunksize()); + chunk_size = (std::min)(static_cast(p_request_context->m_remaining_to_write), + p_request_context->m_http_client->client_config().chunksize()); } p_request_context->allocate_request_space( nullptr, chunk_size + http::details::chunked_encoding::additional_encoding_space); @@ -1370,7 +1403,7 @@ class winhttp_client final : public _http_client_communicator chunk_size + http::details::chunked_encoding::additional_encoding_space, bytes_read); - if (!compressor && p_request_context->m_remaining_to_write != std::numeric_limits::max()) + if (!compressor && p_request_context->m_remaining_to_write != (std::numeric_limits::max)()) { if (bytes_read == 0 && p_request_context->m_remaining_to_write) { @@ -1465,7 +1498,7 @@ class winhttp_client final : public _http_client_communicator p_request_context->m_compression_state.m_bytes_read) { if (p_request_context->m_remaining_to_write && - p_request_context->m_remaining_to_write != std::numeric_limits::max()) + p_request_context->m_remaining_to_write != (std::numeric_limits::max)()) { // The stream ended earlier than we detected it should return pplx::task_from_exception(http_exception( @@ -1518,7 +1551,7 @@ class winhttp_client final : public _http_client_communicator p_request_context->m_compression_state.m_bytes_processed += r.input_bytes_processed; _ASSERTE(p_request_context->m_compression_state.m_bytes_processed <= p_request_context->m_compression_state.m_bytes_read); - if (p_request_context->m_remaining_to_write != std::numeric_limits::max()) + if (p_request_context->m_remaining_to_write != (std::numeric_limits::max)()) { _ASSERTE(p_request_context->m_remaining_to_write >= r.input_bytes_processed); p_request_context->m_remaining_to_write -= r.input_bytes_processed; @@ -1568,7 +1601,7 @@ class winhttp_client final : public _http_client_communicator return; } else if (p_request_context->m_remaining_to_write && - p_request_context->m_remaining_to_write != std::numeric_limits::max()) + p_request_context->m_remaining_to_write != (std::numeric_limits::max)()) { // Unexpected end-of-stream. p_request_context->report_error(GetLastError(), @@ -1586,8 +1619,8 @@ class winhttp_client final : public _http_client_communicator } else { - length = std::min(static_cast(p_request_context->m_remaining_to_write), - p_request_context->m_http_client->client_config().chunksize()); + length = (std::min)(static_cast(p_request_context->m_remaining_to_write), + p_request_context->m_http_client->client_config().chunksize()); if (p_request_context->m_compression_state.m_buffer.capacity() < length) { p_request_context->m_compression_state.m_buffer.reserve(length); @@ -1842,7 +1875,7 @@ class winhttp_client final : public _http_client_communicator if (content_length > 0) { // There is a request body that needs to be transferred. - if (content_length == std::numeric_limits::max()) + if (content_length == (std::numeric_limits::max)()) { // The content length is unknown and the application set a stream. This is an // indication that we will need to chunk the data. @@ -1873,7 +1906,7 @@ class winhttp_client final : public _http_client_communicator static void CALLBACK completion_callback( HINTERNET hRequestHandle, DWORD_PTR context, DWORD statusCode, _In_ void* statusInfo, DWORD statusInfoLength) { - CASABLANCA_UNREFERENCED_PARAMETER(statusInfoLength); + (void)statusInfoLength; std::weak_ptr* p_weak_request_context = reinterpret_cast*>(context); @@ -2208,8 +2241,8 @@ class winhttp_client final : public _http_client_communicator if (p_request_context->m_decompressor) { - size_t chunk_size = std::max(static_cast(bytesRead), - p_request_context->m_http_client->client_config().chunksize()); + size_t chunk_size = (std::max)(static_cast(bytesRead), + p_request_context->m_http_client->client_config().chunksize()); p_request_context->m_compression_state.m_bytes_read = static_cast(bytesRead); p_request_context->m_compression_state.m_chunk_bytes = 0; @@ -2396,24 +2429,23 @@ class winhttp_client final : public _http_client_communicator return keep_going(p_request_context.get()); }); }); - }) - .then([p_request_context](pplx::task op) { - try - { - bool ignored = op.get(); - } - catch (...) + }).then([p_request_context](pplx::task op) { + try + { + bool ignored = op.get(); + } + catch (...) + { + // We're only here to pick up any exception that may have been thrown, and to clean up + // if needed + if (p_request_context->m_compression_state.m_acquired) { - // We're only here to pick up any exception that may have been thrown, and to clean up - // if needed - if (p_request_context->m_compression_state.m_acquired) - { - p_request_context->_get_writebuffer().commit(0); - p_request_context->m_compression_state.m_acquired = nullptr; - } - p_request_context->report_exception(std::current_exception()); + p_request_context->_get_writebuffer().commit(0); + p_request_context->m_compression_state.m_acquired = nullptr; } - }); + p_request_context->report_exception(std::current_exception()); + } + }); } else { diff --git a/Release/src/http/client/http_client_winrt.cpp b/Release/src/http/client/http_client_winrt.cpp index 294227512d..a95d9b3431 100644 --- a/Release/src/http/client/http_client_winrt.cpp +++ b/Release/src/http/client/http_client_winrt.cpp @@ -188,7 +188,7 @@ class IRequestStream final { public: IRequestStream(const std::weak_ptr& context, - size_t read_length = std::numeric_limits::max()) + size_t read_length = (std::numeric_limits::max)()) : m_context(context), m_read_length(read_length) { // read_length is the initial length of the ISequentialStream that is available for read @@ -253,9 +253,9 @@ class IRequestStream final _In_ ULONG cb, _Out_opt_ ULONG* pcbWritten) { - CASABLANCA_UNREFERENCED_PARAMETER(pv); - CASABLANCA_UNREFERENCED_PARAMETER(cb); - CASABLANCA_UNREFERENCED_PARAMETER(pcbWritten); + (void)pv; + (void)cb; + (void)pcbWritten; return E_NOTIMPL; } @@ -345,9 +345,9 @@ class IResponseStream final _In_ ULONG cb, _Out_ ULONG* pcbRead) { - CASABLANCA_UNREFERENCED_PARAMETER(pv); - CASABLANCA_UNREFERENCED_PARAMETER(cb); - CASABLANCA_UNREFERENCED_PARAMETER(pcbRead); + (void)pv; + (void)cb; + (void)pcbRead; return E_NOTIMPL; } @@ -403,7 +403,7 @@ class winrt_client final : public _http_client_communicator } const size_t content_length = msg._get_impl()->_get_content_length(); - if (content_length == std::numeric_limits::max()) + if (content_length == (std::numeric_limits::max)()) { // IXHR2 does not allow transfer encoding chunked. So the user is expected to set the content length request->report_exception(http_exception(L"Content length is not specified in the http headers")); @@ -478,7 +478,7 @@ class winrt_client final : public _http_client_communicator // Set timeout. ULONGLONG timeout = static_cast(config.timeout().count()); - timeout = std::max(timeout, std::numeric_limits::min() + 1); + timeout = (std::max)(timeout, (std::numeric_limits::min)() + 1); hr = winrt_context->m_hRequest->SetProperty(XHR_PROP_TIMEOUT, timeout); if (FAILED(hr)) { diff --git a/Release/src/http/common/http_compression.cpp b/Release/src/http/common/http_compression.cpp index 691914488a..a65adc2468 100644 --- a/Release/src/http/common/http_compression.cpp +++ b/Release/src/http/common/http_compression.cpp @@ -97,7 +97,7 @@ class zlib_compressor_base : public compress_provider #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wtautological-constant-compare" #endif // __clang__ - if (input_size > std::numeric_limits::max() || output_size > std::numeric_limits::max()) + if (input_size > (std::numeric_limits::max)() || output_size > (std::numeric_limits::max)()) #if defined(__clang__) #pragma clang diagnostic pop #endif // __clang__ @@ -198,7 +198,7 @@ class zlib_decompressor_base : public decompress_provider #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wtautological-constant-compare" #endif // __clang__ - if (input_size > std::numeric_limits::max() || output_size > std::numeric_limits::max()) + if (input_size > (std::numeric_limits::max)() || output_size > (std::numeric_limits::max)()) #if defined(__clang__) #pragma clang diagnostic pop #endif // __clang__ diff --git a/Release/src/http/common/http_msg.cpp b/Release/src/http/common/http_msg.cpp index 50332fd1e9..c32dfcfaaa 100644 --- a/Release/src/http/common/http_msg.cpp +++ b/Release/src/http/common/http_msg.cpp @@ -287,11 +287,7 @@ static const utility::char_t* stream_was_set_explicitly = static const utility::char_t* unsupported_charset = _XPLATSTR("Charset must be iso-8859-1, utf-8, utf-16, utf-16le, or utf-16be to be extracted."); -http_msg_base::http_msg_base() - : m_http_version(http::http_version{ 0, 0 }) - , m_headers() - , m_default_outstream(false) -{} +http_msg_base::http_msg_base() : m_http_version(http::http_version {0, 0}), m_headers(), m_default_outstream(false) {} void http_msg_base::_prepare_to_receive_data() { @@ -326,7 +322,7 @@ size_t http_msg_base::_get_stream_length() return static_cast(end - offset); } - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); } size_t http_msg_base::_get_content_length(bool honor_compression) @@ -356,7 +352,7 @@ size_t http_msg_base::_get_content_length(bool honor_compression) } } - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); } if (honor_compression && m_compressor) @@ -365,7 +361,7 @@ size_t http_msg_base::_get_content_length(bool honor_compression) // up front for content encoding. We return the uncompressed length if we can figure it out. headers().add(header_names::transfer_encoding, m_compressor->algorithm()); headers().add(header_names::transfer_encoding, _XPLATSTR("chunked")); - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); } if (headers().match(header_names::content_length, content_length)) @@ -376,7 +372,7 @@ size_t http_msg_base::_get_content_length(bool honor_compression) } content_length = _get_stream_length(); - if (content_length != std::numeric_limits::max()) + if (content_length != (std::numeric_limits::max)()) { // The content length wasn't explicitly set, but we figured it out; // use it, since sending this way is more efficient than chunking @@ -386,7 +382,7 @@ size_t http_msg_base::_get_content_length(bool honor_compression) // We don't know the content length; we'll chunk the stream headers().add(header_names::transfer_encoding, _XPLATSTR("chunked")); - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); } // There is no content diff --git a/Release/src/http/listener/http_server_asio.cpp b/Release/src/http/listener/http_server_asio.cpp index 96a24f6be6..f1d8c819c5 100644 --- a/Release/src/http/listener/http_server_asio.cpp +++ b/Release/src/http/listener/http_server_asio.cpp @@ -175,7 +175,7 @@ class hostport_listener auto path_segments = uri::split_path(uri::decode(u.path())); for (auto i = static_cast(path_segments.size()); i >= 0; --i) { - std::string path = ""; + std::string path; for (size_t j = 0; j < static_cast(i); ++j) { path += "/" + utility::conversions::to_utf8string(path_segments[j]); @@ -520,9 +520,9 @@ void hostport_listener::start() auto& service = crossplat::threadpool::shared_instance().service(); tcp::resolver resolver(service); // #446: boost resolver does not recognize "+" as a host wildchar - tcp::resolver::query query = ("+" == m_host) ? - tcp::resolver::query(m_port, boost::asio::ip::resolver_query_base::flags()) : - tcp::resolver::query(m_host, m_port, boost::asio::ip::resolver_query_base::flags()); + tcp::resolver::query query = + ("+" == m_host) ? tcp::resolver::query(m_port, boost::asio::ip::resolver_query_base::flags()) + : tcp::resolver::query(m_host, m_port, boost::asio::ip::resolver_query_base::flags()); tcp::endpoint endpoint = *resolver.resolve(query); @@ -828,7 +828,7 @@ will_deref_and_erase_t asio_server_connection::handle_headers() m_read = 0; ++m_refs; async_read_until_buffersize( - std::min(ChunkSize, m_read_size), + (std::min)(ChunkSize, m_read_size), [this](const boost::system::error_code& ec, size_t) { (will_deref_t) this->handle_body(ec); }); } @@ -910,7 +910,7 @@ will_deref_t asio_server_connection::handle_body(const boost::system::error_code auto writebuf = requestImpl->outstream().streambuf(); writebuf .putn_nocopy(boost::asio::buffer_cast(m_request_buf.data()), - std::min(m_request_buf.size(), m_read_size - m_read)) + (std::min)(m_request_buf.size(), m_read_size - m_read)) .then([this](pplx::task writtenSizeTask) -> will_deref_t { size_t writtenSize = 0; try @@ -926,7 +926,7 @@ will_deref_t asio_server_connection::handle_body(const boost::system::error_code m_request_buf.consume(writtenSize); async_read_until_buffersize( - std::min(ChunkSize, m_read_size - m_read), + (std::min)(ChunkSize, m_read_size - m_read), [this](const boost::system::error_code& ec, size_t) { (will_deref_t) this->handle_body(ec); }); return will_deref_t {}; }); @@ -1162,7 +1162,7 @@ will_deref_and_erase_t asio_server_connection::handle_write_large_response(const if (readbuf.is_eof()) return cancel_sending_response_with_error( response, std::make_exception_ptr(http_exception("Response stream close early!"))); - size_t readBytes = std::min(ChunkSize, m_write_size - m_write); + size_t readBytes = (std::min)(ChunkSize, m_write_size - m_write); readbuf.getn(buffer_cast(m_response_buf.prepare(readBytes)), readBytes) .then([=](pplx::task actualSizeTask) -> will_deref_and_erase_t { size_t actualSize = 0; diff --git a/Release/src/http/listener/http_server_httpsys.cpp b/Release/src/http/listener/http_server_httpsys.cpp index 49d83fe874..d4c080a76b 100644 --- a/Release/src/http/listener/http_server_httpsys.cpp +++ b/Release/src/http/listener/http_server_httpsys.cpp @@ -155,7 +155,7 @@ void parse_http_headers(const HTTP_REQUEST_HEADERS& headers, http::http_headers& } else { - msgHeaders[unknown_header_name] = U(""); + msgHeaders[unknown_header_name].clear(); } } for (int i = 0; i < HttpHeaderMaximum; ++i) @@ -976,10 +976,10 @@ void windows_request_context::async_process_response() // OK, so we need to chunk it up. _ASSERTE(content_length > 0); - m_sending_in_chunks = (content_length != std::numeric_limits::max()); - m_transfer_encoding = (content_length == std::numeric_limits::max()); + m_sending_in_chunks = (content_length != (std::numeric_limits::max)()); + m_transfer_encoding = (content_length == (std::numeric_limits::max)()); m_remaining_to_write = content_length; - if (content_length == std::numeric_limits::max()) + if (content_length == (std::numeric_limits::max)()) { // Attempt to figure out the remaining length of the input stream m_remaining_to_write = m_response._get_impl()->_get_stream_length(); diff --git a/Release/src/http/listener/http_server_httpsys.h b/Release/src/http/listener/http_server_httpsys.h index d998619bbe..40c2a5e9ab 100644 --- a/Release/src/http/listener/http_server_httpsys.h +++ b/Release/src/http/listener/http_server_httpsys.h @@ -58,9 +58,9 @@ class http_overlapped : public OVERLAPPED ULONG_PTR numberOfBytesTransferred, PTP_IO io) { - CASABLANCA_UNREFERENCED_PARAMETER(io); - CASABLANCA_UNREFERENCED_PARAMETER(context); - CASABLANCA_UNREFERENCED_PARAMETER(instance); + (void)io; + (void)context; + (void)instance; http_overlapped* p_http_overlapped = (http_overlapped*)pOverlapped; p_http_overlapped->m_http_io_completion(result, (DWORD)numberOfBytesTransferred); diff --git a/Release/src/http/oauth/oauth1.cpp b/Release/src/http/oauth/oauth1.cpp index 0e973aa401..b313cfcdb3 100644 --- a/Release/src/http/oauth/oauth1.cpp +++ b/Release/src/http/oauth/oauth1.cpp @@ -15,7 +15,7 @@ #include "cpprest/asyncrt_utils.h" -#if !defined(CPPREST_TARGET_XP) +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA using namespace utility; using web::http::client::http_client; @@ -455,4 +455,4 @@ const oauth1_token& oauth1_config::token() const } // namespace http } // namespace web -#endif +#endif // _WIN32_WINNT >= _WIN32_WINNT_VISTA diff --git a/Release/src/json/json.cpp b/Release/src/json/json.cpp index 7b61a179cc..7614866acc 100644 --- a/Release/src/json/json.cpp +++ b/Release/src/json/json.cpp @@ -286,8 +286,9 @@ bool web::json::number::is_int32() const switch (m_type) { case signed_type: - return m_intval >= std::numeric_limits::min() && m_intval <= std::numeric_limits::max(); - case unsigned_type: return m_uintval <= std::numeric_limits::max(); + return m_intval >= (std::numeric_limits::min)() && + m_intval <= (std::numeric_limits::max)(); + case unsigned_type: return m_uintval <= (std::numeric_limits::max)(); case double_type: default: return false; } @@ -297,8 +298,8 @@ bool web::json::number::is_uint32() const { switch (m_type) { - case signed_type: return m_intval >= 0 && m_intval <= std::numeric_limits::max(); - case unsigned_type: return m_uintval <= std::numeric_limits::max(); + case signed_type: return m_intval >= 0 && m_intval <= (std::numeric_limits::max)(); + case unsigned_type: return m_uintval <= (std::numeric_limits::max)(); case double_type: default: return false; } @@ -309,7 +310,7 @@ bool web::json::number::is_int64() const switch (m_type) { case signed_type: return true; - case unsigned_type: return m_uintval <= static_cast(std::numeric_limits::max()); + case unsigned_type: return m_uintval <= static_cast((std::numeric_limits::max)()); case double_type: default: return false; } diff --git a/Release/src/pch/stdafx.h b/Release/src/pch/stdafx.h index d999befe5b..2061bea7f6 100644 --- a/Release/src/pch/stdafx.h +++ b/Release/src/pch/stdafx.h @@ -20,32 +20,29 @@ #endif #ifdef _WIN32 -#define NOMINMAX -#ifdef CPPREST_TARGET_XP -#include -#ifndef _WIN32_WINNT -#define _WIN32_WINNT _WIN32_WINNT_WS03 // Windows XP with SP2 -#endif -#endif -#include // use the debug version of the CRT if _DEBUG is defined #ifdef _DEBUG #define _CRTDBG_MAP_ALLOC #include -#include -#endif +#endif // _DEBUG +#include #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#if CPPREST_TARGET_XP && _WIN32_WINNT != 0x0501 +#error CPPREST_TARGET_XP implies _WIN32_WINNT == 0x0501 +#endif // CPPREST_TARGET_XP && _WIN32_WINNT != 0x0501 + #include #include // Windows Header Files: -#if !defined(__cplusplus_winrt) +#ifndef __cplusplus_winrt #include +#endif !__cplusplus_winrt -#endif // #if !defined(__cplusplus_winrt) -#else // LINUX or APPLE +#else // LINUX or APPLE #define __STDC_LIMIT_MACROS #include "pthread.h" #include @@ -84,6 +81,7 @@ #include #include #include +#include #include // json diff --git a/Release/src/streams/fileio_posix.cpp b/Release/src/streams/fileio_posix.cpp index 013d910d44..2404196423 100644 --- a/Release/src/streams/fileio_posix.cpp +++ b/Release/src/streams/fileio_posix.cpp @@ -375,7 +375,7 @@ size_t _fill_buffer_fsb(_file_info_impl* fInfo, _filestream_callback* callback, size_t byteCount = count * charSize; if (fInfo->m_buffer == nullptr) { - fInfo->m_bufsize = std::max(PageSize, byteCount); + fInfo->m_bufsize = (std::max)(PageSize, byteCount); fInfo->m_buffer = new char[static_cast(fInfo->m_bufsize)]; fInfo->m_bufoff = fInfo->m_rdpos; @@ -396,7 +396,7 @@ size_t _fill_buffer_fsb(_file_info_impl* fInfo, _filestream_callback* callback, if (bufrem < count) { - fInfo->m_bufsize = std::max(PageSize, byteCount); + fInfo->m_bufsize = (std::max)(PageSize, byteCount); // Then, we allocate a new buffer. @@ -456,7 +456,7 @@ size_t _getn_fsb(Concurrency::streams::details::_file_info* info, if (fInfo->m_buffer_reads) { auto cb = create_callback(fInfo, callback, [=](size_t read) { - auto copy = std::min(read, byteCount); + auto copy = (std::min)(read, byteCount); auto bufoff = fInfo->m_rdpos - fInfo->m_bufoff; memcpy(ptr, fInfo->m_buffer + bufoff * charSize, copy); fInfo->m_atend = copy < byteCount; @@ -467,7 +467,7 @@ size_t _getn_fsb(Concurrency::streams::details::_file_info* info, if (static_cast(read) > 0) { - auto copy = std::min(read, byteCount); + auto copy = (std::min)(read, byteCount); auto bufoff = fInfo->m_rdpos - fInfo->m_bufoff; memcpy(ptr, fInfo->m_buffer + bufoff * charSize, copy); fInfo->m_atend = copy < byteCount; diff --git a/Release/src/streams/fileio_win32.cpp b/Release/src/streams/fileio_win32.cpp index 86b5bd1ddc..97cd6e5e6d 100644 --- a/Release/src/streams/fileio_win32.cpp +++ b/Release/src/streams/fileio_win32.cpp @@ -105,9 +105,9 @@ void CALLBACK IoCompletionCallback(PTP_CALLBACK_INSTANCE instance, ULONG_PTR numberOfBytesTransferred, PTP_IO io) { - CASABLANCA_UNREFERENCED_PARAMETER(io); - CASABLANCA_UNREFERENCED_PARAMETER(ctxt); - CASABLANCA_UNREFERENCED_PARAMETER(instance); + (void)io; + (void)ctxt; + (void)instance; EXTENDED_OVERLAPPED* pExtOverlapped = static_cast(pOverlapped); pExtOverlapped->func(result, static_cast(numberOfBytesTransferred), static_cast(pOverlapped)); diff --git a/Release/src/uri/uri.cpp b/Release/src/uri/uri.cpp index 92781f67a8..3f2414af2c 100644 --- a/Release/src/uri/uri.cpp +++ b/Release/src/uri/uri.cpp @@ -734,7 +734,7 @@ std::map uri::split_query(const utility::s else if (equals_index == 0) { utility::string_t value(key_value_pair.begin() + equals_index + 1, key_value_pair.end()); - results[_XPLATSTR("")] = value; + results[utility::string_t {}] = value; } else { diff --git a/Release/src/utilities/web_utilities.cpp b/Release/src/utilities/web_utilities.cpp index 9316f41f4f..ce00078b79 100644 --- a/Release/src/utilities/web_utilities.cpp +++ b/Release/src/utilities/web_utilities.cpp @@ -27,8 +27,9 @@ namespace web { namespace details { -#if defined(_WIN32) && !defined(CPPREST_TARGET_XP) -#if defined(__cplusplus_winrt) +#ifdef _WIN32 +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA +#ifdef __cplusplus_winrt // Helper function to zero out memory of an IBuffer. void winrt_secure_zero_buffer(Windows::Storage::Streams::IBuffer ^ buffer) @@ -88,7 +89,7 @@ plaintext_string winrt_encryption::decrypt() const return std::move(data); } -#else +#else // ^^^ __cplusplus_winrt ^^^ // vvv !__cplusplus_winrt vvv win32_encryption::win32_encryption(const std::wstring& data) : m_numCharacters(data.size()) { @@ -141,13 +142,14 @@ plaintext_string win32_encryption::decrypt() const return result; } -#endif -#endif +#endif // __cplusplus_winrt +#endif // _WIN32_WINNT >= _WIN32_WINNT_VISTA +#endif // _WIN32 void zero_memory_deleter::operator()(::utility::string_t* data) const { - CASABLANCA_UNREFERENCED_PARAMETER(data); -#if defined(_WIN32) + (void)data; +#ifdef _WIN32 SecureZeroMemory(&(*data)[0], data->size() * sizeof(::utility::string_t::value_type)); delete data; #endif diff --git a/Release/src/websockets/client/ws_client.cpp b/Release/src/websockets/client/ws_client.cpp index f768e968fb..48a40797e6 100644 --- a/Release/src/websockets/client/ws_client.cpp +++ b/Release/src/websockets/client/ws_client.cpp @@ -51,8 +51,7 @@ void websocket_client_task_impl::set_handler() }); m_callback_client->set_close_handler( - [=](websocket_close_status status, const utility::string_t& reason, const std::error_code& error_code) { - CASABLANCA_UNREFERENCED_PARAMETER(status); + [=](websocket_close_status, const utility::string_t& reason, const std::error_code& error_code) { close_pending_tasks_with_error(websocket_exception(error_code, reason)); }); } diff --git a/Release/src/websockets/client/ws_client_winrt.cpp b/Release/src/websockets/client/ws_client_winrt.cpp index 291ba8ce8a..6bb4351cee 100644 --- a/Release/src/websockets/client/ws_client_winrt.cpp +++ b/Release/src/websockets/client/ws_client_winrt.cpp @@ -404,7 +404,7 @@ class winrt_callback_client : public websocket_client_callback_impl, return close(websocket_close_status::normal, _XPLATSTR("Normal")); } - pplx::task close(websocket_close_status status, const utility::string_t& strreason = _XPLATSTR("")) + pplx::task close(websocket_close_status status, const utility::string_t& strreason = {}) { // Send a close frame to the server m_msg_websocket->Close(static_cast(status), Platform::StringReference(strreason.c_str())); diff --git a/Release/src/websockets/client/ws_client_wspp.cpp b/Release/src/websockets/client/ws_client_wspp.cpp index 26fa547d5d..ef9c1d0bd3 100644 --- a/Release/src/websockets/client/ws_client_wspp.cpp +++ b/Release/src/websockets/client/ws_client_wspp.cpp @@ -325,34 +325,32 @@ class wspp_callback_client : public websocket_client_callback_impl, } }); - client.set_ping_handler( - [this](websocketpp::connection_hdl, const std::string& msg) { - if (m_external_message_handler) - { - _ASSERTE(m_state >= CONNECTED && m_state < CLOSED); - websocket_incoming_message incoming_msg; + client.set_ping_handler([this](websocketpp::connection_hdl, const std::string& msg) { + if (m_external_message_handler) + { + _ASSERTE(m_state >= CONNECTED && m_state < CLOSED); + websocket_incoming_message incoming_msg; - incoming_msg.m_msg_type = websocket_message_type::ping; - incoming_msg.m_body = concurrency::streams::container_buffer(msg); + incoming_msg.m_msg_type = websocket_message_type::ping; + incoming_msg.m_body = concurrency::streams::container_buffer(msg); - m_external_message_handler(incoming_msg); - } - return true; - }); + m_external_message_handler(incoming_msg); + } + return true; + }); - client.set_pong_handler( - [this](websocketpp::connection_hdl, const std::string& msg) { - if (m_external_message_handler) - { - _ASSERTE(m_state >= CONNECTED && m_state < CLOSED); - websocket_incoming_message incoming_msg; + client.set_pong_handler([this](websocketpp::connection_hdl, const std::string& msg) { + if (m_external_message_handler) + { + _ASSERTE(m_state >= CONNECTED && m_state < CLOSED); + websocket_incoming_message incoming_msg; - incoming_msg.m_msg_type = websocket_message_type::pong; - incoming_msg.m_body = concurrency::streams::container_buffer(msg); + incoming_msg.m_msg_type = websocket_message_type::pong; + incoming_msg.m_body = concurrency::streams::container_buffer(msg); - m_external_message_handler(incoming_msg); - } - }); + m_external_message_handler(incoming_msg); + } + }); client.set_close_handler([this](websocketpp::connection_hdl con_hdl) { _ASSERTE(m_state != CLOSED); @@ -469,7 +467,8 @@ class wspp_callback_client : public websocket_client_callback_impl, } const auto length = msg.m_length; - if (length == 0 && msg.m_msg_type != websocket_message_type::ping && msg.m_msg_type != websocket_message_type::pong) + if (length == 0 && msg.m_msg_type != websocket_message_type::ping && + msg.m_msg_type != websocket_message_type::pong) { return pplx::task_from_exception(websocket_exception("Cannot send empty message.")); } diff --git a/Release/tests/common/TestRunner/test_runner.cpp b/Release/tests/common/TestRunner/test_runner.cpp index 4d1a8d39f9..9a356a9b0f 100644 --- a/Release/tests/common/TestRunner/test_runner.cpp +++ b/Release/tests/common/TestRunner/test_runner.cpp @@ -238,7 +238,7 @@ static int parse_command_line(int argc, char** argv) } else { - UnitTest::GlobalSettings::Add(arg.substr(1), ""); + UnitTest::GlobalSettings::Add(arg.substr(1), std::string{}); } } else if (arg.find("/debug") == 0) @@ -262,9 +262,9 @@ static bool matched_properties(const UnitTest::TestProperties& test_props) // This starts with visual studio versions after VS 2012. #if defined(_MSC_VER) && (_MSC_VER >= 1800) #ifdef WINRT_TEST_RUNNER - UnitTest::GlobalSettings::Add("winrt", ""); + UnitTest::GlobalSettings::Add("winrt", std::string{}); #elif defined DESKTOP_TEST_RUNNER - UnitTest::GlobalSettings::Add("desktop", ""); + UnitTest::GlobalSettings::Add("desktop", std::string{}); #endif #endif diff --git a/Release/tests/common/UnitTestpp/src/Checks.h b/Release/tests/common/UnitTestpp/src/Checks.h index 4425fed100..f4494069b3 100644 --- a/Release/tests/common/UnitTestpp/src/Checks.h +++ b/Release/tests/common/UnitTestpp/src/Checks.h @@ -103,7 +103,7 @@ struct BuildFailureStringImpl std::string BuildString(const char*, const char*, const T1&, const T2&) { // Don't do anything since operator<< isn't supported. - return ""; + return std::string{}; } }; diff --git a/Release/tests/common/UnitTestpp/src/DeferredTestResult.cpp b/Release/tests/common/UnitTestpp/src/DeferredTestResult.cpp index 5800eeb6f1..703031f9fc 100644 --- a/Release/tests/common/UnitTestpp/src/DeferredTestResult.cpp +++ b/Release/tests/common/UnitTestpp/src/DeferredTestResult.cpp @@ -54,12 +54,12 @@ DeferredTestFailure::DeferredTestFailure(int lineNumber_, const char* failureStr } DeferredTestResult::DeferredTestResult() - : suiteName(""), testName(""), failureFile(""), timeElapsed(0.0f), failed(false) + : suiteName(), testName(), failureFile(), timeElapsed(0.0f), failed(false) { } -DeferredTestResult::DeferredTestResult(char const* suite, char const* test) - : suiteName(suite), testName(test), failureFile(""), timeElapsed(0.0f), failed(false) +DeferredTestResult::DeferredTestResult(char const* const suite, char const* const test) + : suiteName(suite), testName(test), failureFile(), timeElapsed(0.0f), failed(false) { } diff --git a/Release/tests/common/UnitTestpp/src/MemoryOutStream.cpp b/Release/tests/common/UnitTestpp/src/MemoryOutStream.cpp index c16845efb8..a0da2e4868 100644 --- a/Release/tests/common/UnitTestpp/src/MemoryOutStream.cpp +++ b/Release/tests/common/UnitTestpp/src/MemoryOutStream.cpp @@ -174,7 +174,7 @@ void MemoryOutStream::GrowBuffer(int const desiredCapacity) if (m_buffer) strcpy(buffer, m_buffer); else - strcpy(buffer, ""); + *buffer = '\0'; delete[] m_buffer; m_buffer = buffer; diff --git a/Release/tests/common/UnitTestpp/src/stdafx.h b/Release/tests/common/UnitTestpp/src/stdafx.h index 14b38623cb..99e91a15ee 100644 --- a/Release/tests/common/UnitTestpp/src/stdafx.h +++ b/Release/tests/common/UnitTestpp/src/stdafx.h @@ -49,6 +49,5 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN -#define NOMINMAX #include #endif \ No newline at end of file diff --git a/Release/tests/common/utilities/os_utilities.cpp b/Release/tests/common/utilities/os_utilities.cpp index de2a06d9fb..12aa4be6ef 100644 --- a/Release/tests/common/utilities/os_utilities.cpp +++ b/Release/tests/common/utilities/os_utilities.cpp @@ -12,7 +12,6 @@ #include "os_utilities.h" #ifdef WIN32 -#define NOMINMAX #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include diff --git a/Release/tests/functional/http/client/compression_tests.cpp b/Release/tests/functional/http/client/compression_tests.cpp index 128006431b..1ccb740fab 100644 --- a/Release/tests/functional/http/client/compression_tests.cpp +++ b/Release/tests/functional/http/client/compression_tests.cpp @@ -73,7 +73,7 @@ SUITE(compression_tests) << " / " << _size; throw std::runtime_error(std::move(ss.str())); } - bytes = std::min(input_size, output_size); + bytes = (std::min)(input_size, output_size); if (bytes) { memcpy(output, input, bytes); @@ -128,7 +128,7 @@ SUITE(compression_tests) << " / " << _size; throw std::runtime_error(std::move(ss.str())); } - bytes = std::min(input_size, output_size); + bytes = (std::min)(input_size, output_size); if (bytes) { memcpy(output, input, bytes); @@ -218,18 +218,18 @@ SUITE(compression_tests) if (csize == cmpsize) { // extend the output buffer if there may be more compressed bytes to retrieve - cmpsize += std::min(chunk_size, (size_t)200); + cmpsize += (std::min)(chunk_size, (size_t)200); cmp_buffer.resize(cmpsize); } r = compressor ->compress(input_buffer.data() + i, - std::min(chunk_size, buffer_size - i), + (std::min)(chunk_size, buffer_size - i), cmp_buffer.data() + csize, - std::min(chunk_size, cmpsize - csize), + (std::min)(chunk_size, cmpsize - csize), hint) .get(); - VERIFY_IS_TRUE(r.input_bytes_processed == std::min(chunk_size, buffer_size - i) || - r.output_bytes_produced == std::min(chunk_size, cmpsize - csize)); + VERIFY_IS_TRUE(r.input_bytes_processed == (std::min)(chunk_size, buffer_size - i) || + r.output_bytes_produced == (std::min)(chunk_size, cmpsize - csize)); VERIFY_IS_TRUE(hint == operation_hint::is_last || !r.done); chunk_sizes.push_back(r.output_bytes_produced); csize += r.output_bytes_produced; @@ -262,7 +262,7 @@ SUITE(compression_tests) ->decompress(cmp_buffer.data() + nn, *it, dcmp_buffer.data() + dsize, - std::min(chunk_size, buffer_size - dsize), + (std::min)(chunk_size, buffer_size - dsize), hint) .get(); nn += *it; @@ -281,14 +281,14 @@ SUITE(compression_tests) memset(dcmp_buffer.data(), 0, dcmp_buffer.size()); do { - size_t n = std::min(chunk_size, csize - nn); + size_t n = (std::min)(chunk_size, csize - nn); do { r = decompressor ->decompress(cmp_buffer.data() + nn, n, dcmp_buffer.data() + dsize, - std::min(chunk_size, buffer_size - dsize), + (std::min)(chunk_size, buffer_size - dsize), operation_hint::has_more) .get(); dsize += r.output_bytes_produced; @@ -770,7 +770,7 @@ SUITE(compression_tests) } #endif // _WIN32 - auto extra_size = [](size_t bufsz) -> size_t { return std::max(static_cast(128), bufsz / 1000); }; + auto extra_size = [](size_t bufsz) -> size_t { return (std::max)(static_cast(128), bufsz / 1000); }; // Test decompression both explicitly through the test server and implicitly through the listener; // this is the top-level loop in order to avoid thrashing the listeners more than necessary diff --git a/Release/tests/functional/http/client/outside_tests.cpp b/Release/tests/functional/http/client/outside_tests.cpp index 41709bc3a1..3ff1a809ec 100644 --- a/Release/tests/functional/http/client/outside_tests.cpp +++ b/Release/tests/functional/http/client/outside_tests.cpp @@ -352,7 +352,7 @@ SUITE(outside_tests) throw; } #else - CASABLANCA_UNREFERENCED_PARAMETER(e); + (void)e; throw; #endif os_utilities::sleep(1000); diff --git a/Release/tests/functional/http/utilities/stdafx.h b/Release/tests/functional/http/utilities/stdafx.h index 9ce41e4b72..23e69e4535 100644 --- a/Release/tests/functional/http/utilities/stdafx.h +++ b/Release/tests/functional/http/utilities/stdafx.h @@ -13,7 +13,6 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN -#define NOMINMAX #include #include diff --git a/Release/tests/functional/json/json_numbers_tests.cpp b/Release/tests/functional/json/json_numbers_tests.cpp index 4935a6af27..538d44d367 100644 --- a/Release/tests/functional/json/json_numbers_tests.cpp +++ b/Release/tests/functional/json/json_numbers_tests.cpp @@ -258,8 +258,8 @@ SUITE(json_numbers_tests) // unsigned int64 max oracleStream.precision(std::numeric_limits::digits10 + 2); - oracleStream << std::numeric_limits::max(); - json::value iMax(std::numeric_limits::max()); + oracleStream << (std::numeric_limits::max)(); + json::value iMax((std::numeric_limits::max)()); VERIFY_ARE_EQUAL(oracleStream.str(), iMax.serialize()); iMax.serialize(stream); VERIFY_ARE_EQUAL(oracleStream.str(), stream.str()); @@ -268,8 +268,8 @@ SUITE(json_numbers_tests) stream.str(U("")); oracleStream.str(U("")); oracleStream.clear(); - oracleStream << std::numeric_limits::min(); - json::value iMin(std::numeric_limits::min()); + oracleStream << (std::numeric_limits::min)(); + json::value iMin((std::numeric_limits::min)()); VERIFY_ARE_EQUAL(oracleStream.str(), iMin.serialize()); iMin.serialize(stream); VERIFY_ARE_EQUAL(oracleStream.str(), stream.str()); @@ -278,8 +278,8 @@ SUITE(json_numbers_tests) stream.str(U("")); oracleStream.str(U("")); oracleStream.precision(std::numeric_limits::digits10 + 2); - oracleStream << std::numeric_limits::max(); - json::value dMax(std::numeric_limits::max()); + oracleStream << (std::numeric_limits::max)(); + json::value dMax((std::numeric_limits::max)()); VERIFY_ARE_EQUAL(oracleStream.str(), dMax.serialize()); dMax.serialize(stream); VERIFY_ARE_EQUAL(oracleStream.str(), stream.str()); @@ -287,8 +287,8 @@ SUITE(json_numbers_tests) // double min stream.str(U("")); oracleStream.str(U("")); - oracleStream << std::numeric_limits::min(); - json::value dMin(std::numeric_limits::min()); + oracleStream << (std::numeric_limits::min)(); + json::value dMin((std::numeric_limits::min)()); VERIFY_ARE_EQUAL(oracleStream.str(), dMin.serialize()); dMin.serialize(stream); VERIFY_ARE_EQUAL(oracleStream.str(), stream.str()); diff --git a/Release/tests/functional/json/stdafx.h b/Release/tests/functional/json/stdafx.h index bb65303dca..bb43264b61 100644 --- a/Release/tests/functional/json/stdafx.h +++ b/Release/tests/functional/json/stdafx.h @@ -16,5 +16,4 @@ #include "unittestpp.h" #include -#define NOMINMAX #include "json_tests.h" diff --git a/Release/tests/functional/misc/atl_headers/header_test1.cpp b/Release/tests/functional/misc/atl_headers/header_test1.cpp index 46d54ff2e3..95dd22359d 100644 --- a/Release/tests/functional/misc/atl_headers/header_test1.cpp +++ b/Release/tests/functional/misc/atl_headers/header_test1.cpp @@ -11,7 +11,6 @@ // Include ATL headers before casablanca headers #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#define NOMINMAX #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit #ifndef VC_EXTRALEAN diff --git a/Release/tests/functional/misc/atl_headers/header_test2.cpp b/Release/tests/functional/misc/atl_headers/header_test2.cpp index 91cf63fbc6..73e35711de 100644 --- a/Release/tests/functional/misc/atl_headers/header_test2.cpp +++ b/Release/tests/functional/misc/atl_headers/header_test2.cpp @@ -9,7 +9,6 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#define NOMINMAX #include "cpprest/http_client.h" // Include ATL headers after casablanca headers diff --git a/Release/tests/functional/pplx/pplx_test/stdafx.h b/Release/tests/functional/pplx/pplx_test/stdafx.h index 7c2d53ab4f..790829ef64 100644 --- a/Release/tests/functional/pplx/pplx_test/stdafx.h +++ b/Release/tests/functional/pplx/pplx_test/stdafx.h @@ -12,7 +12,6 @@ #pragma once #ifdef _WIN32 -#define NOMINMAX #include #endif diff --git a/Release/tests/functional/streams/istream_tests.cpp b/Release/tests/functional/streams/istream_tests.cpp index d1018e3116..32cb545aa2 100644 --- a/Release/tests/functional/streams/istream_tests.cpp +++ b/Release/tests/functional/streams/istream_tests.cpp @@ -1333,7 +1333,7 @@ SUITE(istream_tests) const auto actual = istream_double.extract().get(); compare_double(expected, actual); - if (actual <= std::numeric_limits::max()) + if (actual <= (std::numeric_limits::max)()) compare_float(float(expected), istream_float.extract().get()); else VERIFY_THROWS(istream_float.extract().get(), std::exception); diff --git a/Release/tests/functional/streams/memstream_tests.cpp b/Release/tests/functional/streams/memstream_tests.cpp index 6442883327..3bdbd6812a 100644 --- a/Release/tests/functional/streams/memstream_tests.cpp +++ b/Release/tests/functional/streams/memstream_tests.cpp @@ -13,7 +13,6 @@ #include #endif #ifdef _WIN32 -#define NOMINMAX #include #endif diff --git a/Release/tests/functional/utils/win32_encryption_tests.cpp b/Release/tests/functional/utils/win32_encryption_tests.cpp index 32e6ab2ecb..a2be7cde5a 100644 --- a/Release/tests/functional/utils/win32_encryption_tests.cpp +++ b/Release/tests/functional/utils/win32_encryption_tests.cpp @@ -21,7 +21,7 @@ namespace functional { namespace utils_tests { -#if defined(_WIN32) && !defined(CPPREST_TARGET_XP) && !defined(__cplusplus_winrt) +#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA && !defined(__cplusplus_winrt) SUITE(win32_encryption) { TEST(win32_encryption_random_string) @@ -42,7 +42,7 @@ SUITE(win32_encryption) } // SUITE(win32_encryption) -#endif +#endif // defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA && !defined(__cplusplus_winrt) } // namespace utils_tests } // namespace functional diff --git a/Release/tests/functional/websockets/utilities/stdafx.h b/Release/tests/functional/websockets/utilities/stdafx.h index e8adb749c9..0c6e35125a 100644 --- a/Release/tests/functional/websockets/utilities/stdafx.h +++ b/Release/tests/functional/websockets/utilities/stdafx.h @@ -13,7 +13,6 @@ #if defined(_WIN32) // Include first to avoid any issues with Windows.h. -#define NOMINMAX #include #endif From 60e067e71aebebdda5d82955060f5f0821c9df1d Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Tue, 16 Jul 2019 07:55:55 -0700 Subject: [PATCH 07/13] Remove proxy settings detection behavior in "default proxy mode." (#1188) * Remove proxy settings detection behavior in "default proxy mode." This commit partially reverts https://github.com/microsoft/cpprestsdk/commit/eb108ada1ab23a46a09efb87f35c802e57e0832a in order to work around a reliability problem with WinHttpGetProxyForUrl. That function hangs unless there is an available thread pool thread to complete the WPAD request. As a result, if a customer issued ~512 concurrent HTTP requests, or otherwise needed that many thread pool threads, there would not be a thread available for WinHTTP to complete the operation, and the program would deadlock. Moreover this call to WinHttpGetDefaultProxyConfiguration is extremely expensive, taking ~20% of overall CPU for the entire program for some Azure Storage SDK customers. The function WinHttpGetProxyForUrlEx is supposed to help with this problem by being asynchronous, but that function was added in Windows 8, so we can't use it unconditionally. And on Windows 8.1 we already are using WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY instead of trying to do proxy autodetect ourselves. --- .../include/cpprest/details/web_utilities.h | 4 -- .../src/http/client/http_client_winhttp.cpp | 62 ++++++++++--------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Release/include/cpprest/details/web_utilities.h b/Release/include/cpprest/details/web_utilities.h index aed7419c85..853d7614b1 100644 --- a/Release/include/cpprest/details/web_utilities.h +++ b/Release/include/cpprest/details/web_utilities.h @@ -10,10 +10,6 @@ ****/ #pragma once -#ifdef _WIN32 -#include -#endif // _WIN32 - #include "cpprest/asyncrt_utils.h" #include "cpprest/uri.h" diff --git a/Release/src/http/client/http_client_winhttp.cpp b/Release/src/http/client/http_client_winhttp.cpp index a6e5a226b1..249bfcd52c 100644 --- a/Release/src/http/client/http_client_winhttp.cpp +++ b/Release/src/http/client/http_client_winhttp.cpp @@ -243,6 +243,24 @@ enum msg_body_type transfer_encoding_chunked }; +static DWORD WinHttpDefaultProxyConstant() CPPREST_NOEXCEPT +{ +#if _WIN32_WINNT >= _WIN32_WINNT_VISTA +#if _WIN32_WINNT < _WIN32_WINNT_WINBLUE + if (!IsWindows8Point1OrGreater()) + { + // Not Windows 8.1 or later, use the default proxy setting + return WINHTTP_ACCESS_TYPE_DEFAULT_PROXY; + } +#endif // _WIN32_WINNT < _WIN32_WINNT_WINBLUE + + // Windows 8.1 or later, use the automatic proxy setting + return WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY; +#else // ^^^ _WIN32_WINNT >= _WIN32_WINNT_VISTA ^^^ // vvv _WIN32_WINNT < _WIN32_WINNT_VISTA vvv + return WINHTTP_ACCESS_TYPE_DEFAULT_PROXY; +#endif // _WIN32_WINNT >= _WIN32_WINNT_VISTA +} + // Additional information necessary to track a WinHTTP request. class winhttp_request_context final : public request_context { @@ -818,38 +836,30 @@ class winhttp_client final : public _http_client_communicator ie_proxy_config proxyIE; DWORD access_type; - LPCWSTR proxy_name; + LPCWSTR proxy_name = WINHTTP_NO_PROXY_NAME; LPCWSTR proxy_bypass = WINHTTP_NO_PROXY_BYPASS; + m_proxy_auto_config = false; utility::string_t proxy_str; http::uri uri; const auto& config = client_config(); - - if (config.proxy().is_disabled()) + const auto& proxy = config.proxy(); + if (proxy.is_default()) + { + access_type = WinHttpDefaultProxyConstant(); + } + else if (proxy.is_disabled()) { access_type = WINHTTP_ACCESS_TYPE_NO_PROXY; - proxy_name = WINHTTP_NO_PROXY_NAME; } - else if (config.proxy().is_default() || config.proxy().is_auto_discovery()) + else if (proxy.is_auto_discovery()) { - // Use the default WinHTTP proxy by default. - access_type = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY; - proxy_name = WINHTTP_NO_PROXY_NAME; - -#if _WIN32_WINNT < _WIN32_WINNT_VISTA - if (config.proxy().is_auto_discovery()) + access_type = WinHttpDefaultProxyConstant(); + if (access_type != WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY) { + // Windows 8 or earlier, do proxy autodetection ourselves m_proxy_auto_config = true; - } -#else // ^^^ _WIN32_WINNT < _WIN32_WINNT_VISTA ^^^ // vvv _WIN32_WINNT >= _WIN32_WINNT_VISTA vvv - if (IsWindows8Point1OrGreater()) - { - // Windows 8.1 and newer supports automatic proxy discovery and auto-fallback to IE proxy settings - access_type = WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY; - } - else - { - // However, if it is not configured... + proxy_info proxyDefault; if (!WinHttpGetDefaultProxyConfiguration(&proxyDefault) || proxyDefault.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY) @@ -881,13 +891,7 @@ class winhttp_client final : public _http_client_communicator } } } - - if (config.proxy().is_auto_discovery()) - { - m_proxy_auto_config = true; - } } -#endif // _WIN32_WINNT < _WIN32_WINNT_VISTA } else { @@ -1007,9 +1011,7 @@ class winhttp_client final : public _http_client_communicator if (m_proxy_auto_config) { - WINHTTP_AUTOPROXY_OPTIONS autoproxy_options; - memset(&autoproxy_options, 0, sizeof(WINHTTP_AUTOPROXY_OPTIONS)); - + WINHTTP_AUTOPROXY_OPTIONS autoproxy_options {}; if (m_proxy_auto_config_url.empty()) { autoproxy_options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT; From 6f602bee67b088a299d7901534af3bce6334ab38 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Tue, 16 Jul 2019 12:07:11 -0700 Subject: [PATCH 08/13] Mint v2.10.14. (#1193) --- Release/CMakeLists.txt | 2 +- Release/include/cpprest/version.h | 2 +- changelog.md | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index b9e6d6d56a..dd5d1daca2 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -11,7 +11,7 @@ endif() set(CPPREST_VERSION_MAJOR 2) set(CPPREST_VERSION_MINOR 10) -set(CPPREST_VERSION_REVISION 13) +set(CPPREST_VERSION_REVISION 14) enable_testing() diff --git a/Release/include/cpprest/version.h b/Release/include/cpprest/version.h index af1a6c7c1d..a6a55e231b 100644 --- a/Release/include/cpprest/version.h +++ b/Release/include/cpprest/version.h @@ -5,6 +5,6 @@ */ #define CPPREST_VERSION_MINOR 10 #define CPPREST_VERSION_MAJOR 2 -#define CPPREST_VERSION_REVISION 13 +#define CPPREST_VERSION_REVISION 14 #define CPPREST_VERSION (CPPREST_VERSION_MAJOR * 100000 + CPPREST_VERSION_MINOR * 100 + CPPREST_VERSION_REVISION) diff --git a/changelog.md b/changelog.md index fd371ec498..3c11c199c6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,22 @@ +cpprestsdk (2.10.14) +* Potential breaking change warning: This release changes the "default" proxy for the WinHTTP backend to go back to WINHTTP_ACCESS_TYPE_DEFAULT_PROXY. See https://github.com/microsoft/cpprestsdk/commit/60e067e71aebebdda5d82955060f5f0821c9df1d for more details. To get automatic WPAD behavior, set the proxy to auto detect. +* macOS with Brew and iOS builds have been disabled and are no longer being tested because our dependency boost for ios project appears to be broken with current releases of XCode as on the Azure Pipelines machines. We are interested in macOS / iOS folks who know what's going on here in contributing a repair to turn this back on. +* PR##1133 Add switches to make apiscan happy. +* PR##1130 json: {"meow"} is not a valid object +* PR##1150 Undefine compress if it is defined by zconf.h +* PR##1156 Fix broken CI Builds +* PR##1155 Use EVP_MAX_MD_SIZE instead of HMAC_MAX_MD_CBLOCK +* PR##1145 Remove the address_configured flag on tcp::resolver::query +* PR##1143 add ping and pong to message handler +* PR##539 Fix reusing ASIO http_client connecting to HTTPS server via proxy +* PR##1175 Fix issue #1171: Order of object destruction +* PR##1183 FIX: SSL proxy tunnel support with basic auth +* PR##1184 Fix profile being set on the compiler instead of the linker. +* PR##1185 Update boost-for-android for Android NDK r20 and disable macOS Homebrew. +* PR##1187 Replace CPPREST_TARGET_XP with version checks, remove ""s, and other cleanup +* PR##1188 Remove proxy settings detection behavior in "default proxy mode." +-- cpprestsdk team TUE, 16 Jul 2019 09:06:00 +0200 + cpprestsdk (2.10.13) * PR#1120 Fix off by one error in leap years before year 2000, and bad day names * PR#1117 Parse and emit years from 1900 to 9999, and remove environment variable dependence on Android From a40a28610db709ce6abc2bd0bd0f16a2e0af7ebd Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley <31761158+garethsb-sony@users.noreply.github.com> Date: Tue, 23 Jul 2019 18:54:40 +0100 Subject: [PATCH 09/13] Missed one defence against no NOMINMAX in bed8fa538c862a8297cb02c99d8b3dcc29247d5b. (#1202) --- Release/src/http/client/http_client_asio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index f8401d6e99..a90ca6a7fa 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -1444,8 +1444,8 @@ class asio_context final : public request_context, public std::enable_shared_fro } } - m_content_length = std::numeric_limits::max(); // Without Content-Length header, size should be same as - // TCP stream - set it size_t max. + m_content_length = (std::numeric_limits::max)(); // Without Content-Length header, size should be same as + // TCP stream - set it size_t max. m_response.headers().match(header_names::content_length, m_content_length); if (!this->handle_compression()) From 44c491889ddbcfca963aa54e175d81f0eade058d Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley <31761158+garethsb-sony@users.noreply.github.com> Date: Fri, 2 Aug 2019 20:27:46 +0100 Subject: [PATCH 10/13] Workarounds for two GCC 4.7.2 bugs with lambda functions (#1209) * Workarounds for two GCC 4.7.2 bugs with lambda functions using implicit this, surfacing as incorrect const-qualification and an internal compiler error. Resolves immediate issues identified in #1200. * Restore compatibility with modern compilers --- Release/src/websockets/client/ws_client_wspp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Release/src/websockets/client/ws_client_wspp.cpp b/Release/src/websockets/client/ws_client_wspp.cpp index ef9c1d0bd3..d7c31c4095 100644 --- a/Release/src/websockets/client/ws_client_wspp.cpp +++ b/Release/src/websockets/client/ws_client_wspp.cpp @@ -292,7 +292,7 @@ class wspp_callback_client : public websocket_client_callback_impl, client.set_fail_handler([this](websocketpp::connection_hdl con_hdl) { _ASSERTE(m_state == CONNECTING); - shutdown_wspp_impl(con_hdl, true); + this->shutdown_wspp_impl(con_hdl, true); }); client.set_message_handler( @@ -354,7 +354,7 @@ class wspp_callback_client : public websocket_client_callback_impl, client.set_close_handler([this](websocketpp::connection_hdl con_hdl) { _ASSERTE(m_state != CLOSED); - shutdown_wspp_impl(con_hdl, false); + this->shutdown_wspp_impl(con_hdl, false); }); // Set User Agent specified by the user. This needs to happen before any connection is created @@ -679,7 +679,7 @@ class wspp_callback_client : public websocket_client_callback_impl, client.stop_perpetual(); // Can't join thread directly since it is the current thread. - pplx::create_task([this, connecting, ec, closeCode, reason] { + pplx::create_task([] {}).then([this, connecting, ec, closeCode, reason]() mutable { { std::lock_guard lock(m_wspp_client_lock); if (m_thread.joinable()) From 265d681743c78c980383340e786109e41c003bd9 Mon Sep 17 00:00:00 2001 From: Jason Hartman Date: Thu, 22 Aug 2019 19:33:30 -0700 Subject: [PATCH 11/13] fix SxS debug-release builds with Visual Studio (#1220) * On basic_string_view_support: fix SxS debug-release builds with Visual Studio place precompiled header implicitly in Debug/Release path with VS and explicitly in bin dir otherwise standardize pch setup across libraries with helper function * nudge pipeline to rerun --- Release/CMakeLists.txt | 22 +++++++++++++++++++ .../BlackJack/BlackJack_Server/CMakeLists.txt | 11 +--------- Release/src/CMakeLists.txt | 13 +---------- .../functional/http/client/CMakeLists.txt | 13 +---------- .../functional/http/listener/CMakeLists.txt | 11 +--------- Release/tests/functional/json/CMakeLists.txt | 13 +---------- .../functional/pplx/pplx_test/CMakeLists.txt | 13 +---------- .../tests/functional/streams/CMakeLists.txt | 13 +---------- Release/tests/functional/uri/CMakeLists.txt | 13 +---------- Release/tests/functional/utils/CMakeLists.txt | 13 +---------- 10 files changed, 31 insertions(+), 104 deletions(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index dd5d1daca2..4b6433a93a 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -202,6 +202,28 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) +function(configure_pch target precompile_header precomile_source) # optional additional compile arguments + if(MSVC) + get_target_property(_srcs ${target} SOURCES) + + set(pch_output_filepath_arg) + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE ${precomile_source} APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/${target}.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.pch") + set(pch_output_filepath_arg "/Fp${CMAKE_CURRENT_BINARY_DIR}/${target}.pch") + else() + # Don't specify output file so that VS may choose a config spefic location. + # Otherwise Debug/Release builds will interfere with one another. + endif() + + set_source_files_properties(${precomile_source} PROPERTIES COMPILE_FLAGS "/Yc${precompile_header}") + target_sources(${target} PRIVATE ${precomile_source}) + # Note: as ${precomile_source} is also a SOURCE for ${target}, the below options will also be applied. + # ${precomile_source} has /Yc option that will cause the shared /Yu to be ignored. + target_compile_options(${target} PRIVATE /Yu${precompile_header} ${pch_output_filepath_arg} ${ARGN}) + endif() +endfunction() + # These settings can be used by the test targets set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) set(Casablanca_LIBRARY cpprest) diff --git a/Release/samples/BlackJack/BlackJack_Server/CMakeLists.txt b/Release/samples/BlackJack/BlackJack_Server/CMakeLists.txt index cddfdc50a8..25d82598bc 100644 --- a/Release/samples/BlackJack/BlackJack_Server/CMakeLists.txt +++ b/Release/samples/BlackJack/BlackJack_Server/CMakeLists.txt @@ -10,13 +10,4 @@ add_executable(blackjackserver target_link_libraries(blackjackserver cpprest) -if(MSVC) - get_target_property(_srcs blackjackserver SOURCES) - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/blackjack-server-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/blackjack-server-stdafx.pch") - endif() - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpblackjack-server-stdafx.pch /Zm120") - target_sources(blackjackserver PRIVATE stdafx.cpp) - target_compile_options(blackjackserver PRIVATE /Yustdafx.h /Fpblackjack-server-stdafx.pch /Zm120) -endif() +configure_pch(blackjackserver stdafx.h stdafx.cpp /Zm120) diff --git a/Release/src/CMakeLists.txt b/Release/src/CMakeLists.txt index 89d2bc55c3..119b07afe2 100644 --- a/Release/src/CMakeLists.txt +++ b/Release/src/CMakeLists.txt @@ -174,18 +174,7 @@ else() message(FATAL_ERROR "Invalid implementation") endif() -if(MSVC) - get_target_property(_srcs cpprest SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE pch/stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") - endif() - - set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Zm120") - target_sources(cpprest PRIVATE pch/stdafx.cpp) - target_compile_options(cpprest PRIVATE /Yustdafx.h /Zm120) -endif() +configure_pch(cpprest stdafx.h pch/stdafx.cpp /Zm120) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(WERROR) diff --git a/Release/tests/functional/http/client/CMakeLists.txt b/Release/tests/functional/http/client/CMakeLists.txt index 45f0d9af02..635e7da843 100644 --- a/Release/tests/functional/http/client/CMakeLists.txt +++ b/Release/tests/functional/http/client/CMakeLists.txt @@ -32,18 +32,7 @@ else() target_link_libraries(httpclient_test PRIVATE httptest_utilities) endif() -if(MSVC) - get_target_property(_srcs httpclient_test SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/client-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/client-tests-stdafx.pch") - endif() - - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpclient-tests-stdafx.pch") - target_sources(httpclient_test PRIVATE stdafx.cpp) - target_compile_options(httpclient_test PRIVATE /Yustdafx.h /Fpclient-tests-stdafx.pch) -endif() +configure_pch(httpclient_test stdafx.h stdafx.cpp) if(NOT WIN32) cpprest_find_boost() diff --git a/Release/tests/functional/http/listener/CMakeLists.txt b/Release/tests/functional/http/listener/CMakeLists.txt index aa4245fed8..58cf86a6fd 100644 --- a/Release/tests/functional/http/listener/CMakeLists.txt +++ b/Release/tests/functional/http/listener/CMakeLists.txt @@ -22,14 +22,5 @@ if(NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) target_link_libraries(httplistener_test PRIVATE httptest_utilities) endif() - if(MSVC) - get_target_property(_srcs httplistener_test SOURCES) - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/listener-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/listener-tests-stdafx.pch") - endif() - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fplistener-tests-stdafx.pch") - target_sources(httplistener_test PRIVATE stdafx.cpp) - target_compile_options(httplistener_test PRIVATE /Yustdafx.h /Fplistener-tests-stdafx.pch) - endif() + configure_pch(httplistener_test stdafx.h stdafx.cpp) endif() diff --git a/Release/tests/functional/json/CMakeLists.txt b/Release/tests/functional/json/CMakeLists.txt index 1d44a99ce6..fb10c885f7 100644 --- a/Release/tests/functional/json/CMakeLists.txt +++ b/Release/tests/functional/json/CMakeLists.txt @@ -16,15 +16,4 @@ if(UNIX AND NOT APPLE) target_link_libraries(json_test PRIVATE cpprestsdk_boost_internal) endif() -if(MSVC) - get_target_property(_srcs json_test SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/json-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/json-tests-stdafx.pch") - endif() - - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpjson-tests-stdafx.pch") - target_sources(json_test PRIVATE stdafx.cpp) - target_compile_options(json_test PRIVATE /Yustdafx.h /Fpjson-tests-stdafx.pch) -endif() +configure_pch(json_test stdafx.h stdafx.cpp) diff --git a/Release/tests/functional/pplx/pplx_test/CMakeLists.txt b/Release/tests/functional/pplx/pplx_test/CMakeLists.txt index 0e2672b73e..7007a5829a 100644 --- a/Release/tests/functional/pplx/pplx_test/CMakeLists.txt +++ b/Release/tests/functional/pplx/pplx_test/CMakeLists.txt @@ -6,15 +6,4 @@ set(SOURCES add_casablanca_test(pplx_test SOURCES) -if(MSVC) - get_target_property(_srcs pplx_test SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/pplx-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pplx-tests-stdafx.pch") - endif() - - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fppplx-tests-stdafx.pch") - target_sources(pplx_test PRIVATE stdafx.cpp) - target_compile_options(pplx_test PRIVATE /Yustdafx.h /Fppplx-tests-stdafx.pch) -endif() +configure_pch(pplx_test stdafx.h stdafx.cpp) diff --git a/Release/tests/functional/streams/CMakeLists.txt b/Release/tests/functional/streams/CMakeLists.txt index 29d09bbac8..92077b0228 100644 --- a/Release/tests/functional/streams/CMakeLists.txt +++ b/Release/tests/functional/streams/CMakeLists.txt @@ -24,15 +24,4 @@ if(NOT WIN32 OR CPPREST_WEBSOCKETS_IMPL STREQUAL "wspp") endif() endif() -if(MSVC) - get_target_property(_srcs streams_test SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/streams-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/streams-tests-stdafx.pch") - endif() - - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpstreams-tests-stdafx.pch") - target_sources(streams_test PRIVATE stdafx.cpp) - target_compile_options(streams_test PRIVATE /Yustdafx.h /Fpstreams-tests-stdafx.pch) -endif() +configure_pch(streams_test stdafx.h stdafx.cpp) diff --git a/Release/tests/functional/uri/CMakeLists.txt b/Release/tests/functional/uri/CMakeLists.txt index e3f7de1da2..298ec21b01 100644 --- a/Release/tests/functional/uri/CMakeLists.txt +++ b/Release/tests/functional/uri/CMakeLists.txt @@ -13,15 +13,4 @@ set(SOURCES add_casablanca_test(uri_test SOURCES) -if(MSVC) - get_target_property(_srcs uri_test SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/uri-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/uri-tests-stdafx.pch") - endif() - - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpuri-tests-stdafx.pch") - target_sources(uri_test PRIVATE stdafx.cpp) - target_compile_options(uri_test PRIVATE /Yustdafx.h /Fpuri-tests-stdafx.pch) -endif() +configure_pch(uri_test stdafx.h stdafx.cpp) diff --git a/Release/tests/functional/utils/CMakeLists.txt b/Release/tests/functional/utils/CMakeLists.txt index 201af77039..a8f157ecdb 100644 --- a/Release/tests/functional/utils/CMakeLists.txt +++ b/Release/tests/functional/utils/CMakeLists.txt @@ -13,15 +13,4 @@ if(CMAKE_COMPILER_IS_GNUCXX) target_compile_options(utils_test PRIVATE "-Wno-deprecated-declarations") endif() -if(MSVC) - get_target_property(_srcs utils_test SOURCES) - - if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") - set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/utils-tests-stdafx.pch") - set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/utils-tests-stdafx.pch") - endif() - - set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fputils-tests-stdafx.pch") - target_sources(utils_test PRIVATE stdafx.cpp) - target_compile_options(utils_test PRIVATE /Yustdafx.h /Fputils-tests-stdafx.pch) -endif() +configure_pch(utils_test stdafx.h stdafx.cpp) From f7065f48a3aba547d00b6aaffbdd0de26b182e44 Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley <31761158+garethsb-sony@users.noreply.github.com> Date: Fri, 23 Aug 2019 03:34:39 +0100 Subject: [PATCH 12/13] Fix "Data" to "Date" in the HTTP Server API mapping, and clarify that the indices of these values match the HTTP_HEADER_ID values for HTTP_REQUEST_HEADERS but *not* HTTP_RESPONSE_HEADERS (#1219) --- .../src/http/listener/http_server_httpsys.cpp | 101 ++++++++---------- .../functional/http/listener/header_tests.cpp | 25 +++++ .../http/utilities/test_http_server.cpp | 101 ++++++++---------- 3 files changed, 117 insertions(+), 110 deletions(-) diff --git a/Release/src/http/listener/http_server_httpsys.cpp b/Release/src/http/listener/http_server_httpsys.cpp index d4c080a76b..318d1404c0 100644 --- a/Release/src/http/listener/http_server_httpsys.cpp +++ b/Release/src/http/listener/http_server_httpsys.cpp @@ -43,62 +43,53 @@ namespace experimental namespace details { /// -/// String values for all HTTP Server API known headers. +/// String values for all HTTP Server API HTTP_REQUEST_HEADERS known headers. /// NOTE: the order here is important it is from the _HTTP_HEADER_ID enum. /// -static utility::string_t HttpServerAPIKnownHeaders[] = {U("Cache-Control"), - U("Connection"), - U("Data"), - U("Keep-Alive"), - U("Pragma"), - U("Trailer"), - U("Transfer-Encoding"), - U("Upgrade"), - U("Via"), - U("Warning"), - U("Allow"), - U("Content-Length"), - U("Content-Type"), - U("Content-Encoding"), - U("Content-Language"), - U("Content-Location"), - U("Content-Md5"), - U("Content-Range"), - U("Expires"), - U("Last-Modified"), - U("Accept"), - U("Accept-Charset"), - U("Accept-Encoding"), - U("Accept-Language"), - U("Authorization"), - U("Cookie"), - U("Expect"), - U("From"), - U("Host"), - U("If-Match"), - U("If-Modified-Since"), - U("If-None-Match"), - U("If-Range"), - U("If-Unmodified-Since"), - U("Max-Forwards"), - U("Proxy-Authorization"), - U("Referer"), - U("Range"), - U("TE"), - U("Translate"), - U("User-Agent"), - U("Request-Maximum"), - U("Accept-Ranges"), - U("Age"), - U("Etag"), - U("Location"), - U("Proxy-Authenticate"), - U("Retry-After"), - U("Server"), - U("Set-Cookie"), - U("Vary"), - U("Www-Authenticate"), - U("Response-Maximum")}; +static utility::string_t HttpServerAPIRequestKnownHeaders[] = +{ + U("Cache-Control"), + U("Connection"), + U("Date"), + U("Keep-Alive"), + U("Pragma"), + U("Trailer"), + U("Transfer-Encoding"), + U("Upgrade"), + U("Via"), + U("Warning"), + U("Allow"), + U("Content-Length"), + U("Content-Type"), + U("Content-Encoding"), + U("Content-Language"), + U("Content-Location"), + U("Content-MD5"), + U("Content-Range"), + U("Expires"), + U("Last-Modified"), + U("Accept"), + U("Accept-Charset"), + U("Accept-Encoding"), + U("Accept-Language"), + U("Authorization"), + U("Cookie"), + U("Expect"), + U("From"), + U("Host"), + U("If-Match"), + U("If-Modified-Since"), + U("If-None-Match"), + U("If-Range"), + U("If-Unmodified-Since"), + U("Max-Forwards"), + U("Proxy-Authorization"), + U("Referer"), + U("Range"), + U("TE"), + U("Translate"), + U("User-Agent") +}; static void char_to_wstring(utf16string& dest, const char* src) { @@ -162,7 +153,7 @@ void parse_http_headers(const HTTP_REQUEST_HEADERS& headers, http::http_headers& { if (headers.KnownHeaders[i].RawValueLength > 0) { - msgHeaders.add(HttpServerAPIKnownHeaders[i], + msgHeaders.add(HttpServerAPIRequestKnownHeaders[i], utility::conversions::to_utf16string(headers.KnownHeaders[i].pRawValue)); } } diff --git a/Release/tests/functional/http/listener/header_tests.cpp b/Release/tests/functional/http/listener/header_tests.cpp index a3cff2e2e1..87cf6783fb 100644 --- a/Release/tests/functional/http/listener/header_tests.cpp +++ b/Release/tests/functional/http/listener/header_tests.cpp @@ -112,6 +112,31 @@ SUITE(header_tests) listener.close().wait(); } + TEST_FIXTURE(uri_address, request_known_headers) + { + http_listener listener(m_uri); + listener.open().wait(); + test_http_client::scoped_client client(m_uri); + test_http_client* p_client = client.client(); + const utility::string_t mtd = methods::GET; + std::map headers; + + // "Date" was being incorrectly mapped to "Data" + // see https://github.com/microsoft/cpprestsdk/issues/1208 + headers[U("Date")] = U("Mon, 29 Jul 2019 12:32:57 GMT"); + listener.support([&](http_request request) { + http_asserts::assert_request_equals(request, mtd, U("/"), headers); + request.reply(status_codes::OK).wait(); + }); + VERIFY_ARE_EQUAL(0, p_client->request(mtd, U(""), headers)); + p_client->next_response() + .then([](test_response* p_response) { + http_asserts::assert_test_response_equals(p_response, status_codes::OK); + }) + .wait(); + listener.close().wait(); + } + TEST_FIXTURE(uri_address, response_headers) { http_listener listener(m_uri); diff --git a/Release/tests/functional/http/utilities/test_http_server.cpp b/Release/tests/functional/http/utilities/test_http_server.cpp index e3a96570ab..3abb6915b6 100644 --- a/Release/tests/functional/http/utilities/test_http_server.cpp +++ b/Release/tests/functional/http/utilities/test_http_server.cpp @@ -97,62 +97,53 @@ static utility::string_t parse_verb(const HTTP_REQUEST* p_http_request) } /// -/// String values for all HTTP Server API known headers. +/// String values for all HTTP Server API HTTP_REQUEST_HEADERS known headers. /// NOTE: the order here is important it is from the _HTTP_HEADER_ID enum. /// -static utility::string_t HttpServerAPIKnownHeaders[] = {U("Cache-Control"), - U("Connection"), - U("Data"), - U("Keep-Alive"), - U("Pragma"), - U("Trailer"), - U("Transfer-Encoding"), - U("Upgrade"), - U("Via"), - U("Warning"), - U("Allow"), - U("Content-Length"), - U("Content-Type"), - U("Content-Encoding"), - U("Content-Language"), - U("Content-Location"), - U("Content-Md5"), - U("Content-Range"), - U("Expires"), - U("Last-Modified"), - U("Accept"), - U("Accept-Charset"), - U("Accept-Encoding"), - U("Accept-Language"), - U("Authorization"), - U("Cookie"), - U("Expect"), - U("From"), - U("Host"), - U("If-Match"), - U("If-Modified-Since"), - U("If-None-Match"), - U("If-Range"), - U("If-Unmodified-Since"), - U("Max-Forwards"), - U("Proxy-Authorization"), - U("Referer"), - U("Range"), - U("TE"), - U("Translate"), - U("User-Agent"), - U("Request-Maximum"), - U("Accept-Ranges"), - U("Age"), - U("Etag"), - U("Location"), - U("Proxy-Authenticate"), - U("Retry-After"), - U("Server"), - U("Set-Cookie"), - U("Vary"), - U("Www-Authenticate"), - U("Response-Maximum")}; +static utility::string_t HttpServerAPIRequestKnownHeaders[] = +{ + U("Cache-Control"), + U("Connection"), + U("Date"), + U("Keep-Alive"), + U("Pragma"), + U("Trailer"), + U("Transfer-Encoding"), + U("Upgrade"), + U("Via"), + U("Warning"), + U("Allow"), + U("Content-Length"), + U("Content-Type"), + U("Content-Encoding"), + U("Content-Language"), + U("Content-Location"), + U("Content-MD5"), + U("Content-Range"), + U("Expires"), + U("Last-Modified"), + U("Accept"), + U("Accept-Charset"), + U("Accept-Encoding"), + U("Accept-Language"), + U("Authorization"), + U("Cookie"), + U("Expect"), + U("From"), + U("Host"), + U("If-Match"), + U("If-Modified-Since"), + U("If-None-Match"), + U("If-Range"), + U("If-Unmodified-Since"), + U("Max-Forwards"), + U("Proxy-Authorization"), + U("Referer"), + U("Range"), + U("TE"), + U("Translate"), + U("User-Agent") +}; static utility::string_t char_to_wstring(const char* src) { @@ -176,7 +167,7 @@ static std::map parse_http_headers(const H { if (headers.KnownHeaders[i].RawValueLength != 0) { - headers_map[HttpServerAPIKnownHeaders[i]] = char_to_wstring(headers.KnownHeaders[i].pRawValue); + headers_map[HttpServerAPIRequestKnownHeaders[i]] = char_to_wstring(headers.KnownHeaders[i].pRawValue); } } return headers_map; From 2a8c17e7bb535674c493afca74d49bf66171b082 Mon Sep 17 00:00:00 2001 From: Michael Khlopin Date: Fri, 23 Aug 2019 05:36:07 +0300 Subject: [PATCH 13/13] Fixing of connections_and_errors::cancel_with_error test which sometimes fires false positive error "There are no pending calls to next_request." (#1196) --- Release/tests/functional/http/client/connections_and_errors.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Release/tests/functional/http/client/connections_and_errors.cpp b/Release/tests/functional/http/client/connections_and_errors.cpp index aea69b8c08..847755d80a 100644 --- a/Release/tests/functional/http/client/connections_and_errors.cpp +++ b/Release/tests/functional/http/client/connections_and_errors.cpp @@ -341,7 +341,9 @@ SUITE(connections_and_errors) test_http_server::scoped_server server(m_uri); pplx::cancellation_token_source source; + const auto r = server.server()->next_request(); responseTask = c.request(methods::GET, U("/"), source.get_token()); + r.wait(); source.cancel(); }